tag:blogger.com,1999:blog-7094652.post3519543689115519938..comments2024-03-23T14:36:09.980+00:00Comments on Neil Mitchell's Blog (Haskell etc): CmdArgs - Fighting the GHC OptimiserNeil Mitchellhttp://www.blogger.com/profile/13084722756124486154noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-7094652.post-22966112980903679132012-06-10T10:54:30.934+01:002012-06-10T10:54:30.934+01:00Or, one could just use the pure version :-) The di...Or, one could just use the pure version :-) The difference in syntax isn't really that bad (for my programs at least). Either way, it works.Anonymoushttps://www.blogger.com/profile/03442904528339254629noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-30827094841888789672012-06-07T12:17:19.903+01:002012-06-07T12:17:19.903+01:00Oren Ben-Kiki: If you change to the style:
sample...Oren Ben-Kiki: If you change to the style:<br /><br />sample = cmdArgsMode $ Sample{hello = ... -- as before<br />main = print =<< cmdArgsRun sample<br /><br />That should solve your problems.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-48819497483090892892012-06-05T16:39:14.620+01:002012-06-05T16:39:14.620+01:00Untracked side effects have other problems than fi...Untracked side effects have other problems than fighting the optimizer. I tried invoking a "main" function using CmdArgs from a test harness and things started failing weirdly if I invoked it more than once.Anonymoushttps://www.blogger.com/profile/03442904528339254629noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-52781059330256958892011-05-10T02:30:20.473+01:002011-05-10T02:30:20.473+01:00In fact, cmdlib has been written as a pure alterna...In fact, cmdlib has been written as a pure alternative to cmdargs. The API may not be perfect but it's not too bad either, and since it's pure it is also fairly composable. Suggestions for API improvements are of course welcome.mornfallhttps://www.blogger.com/profile/17693299507858453330noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-7678529041276743602011-05-08T11:59:03.609+01:002011-05-08T11:59:03.609+01:00Don: Totally correct, I've updated - describin...Don: Totally correct, I've updated - describing CmdArgs as unsafe and untracked side effects.<br /><br />Sterl: I've had this as a plan for a while: http://code.google.com/p/ndmitchell/issues/detail?id=334 - however, lots of people don't like using Template Haskell/QuasiQuoting, so I don't think it will ever be the default.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-46526670730199968392011-05-08T03:50:18.092+01:002011-05-08T03:50:18.092+01:00+1 for rewriting the library to remove unsafePerfo...+1 for rewriting the library to remove unsafePerformIO. A template-haskell/quasiquotation solution would be one approach that provides an easy syntax while avoiding the unsafePerformIO pitfalls.Sterlnoreply@blogger.comtag:blogger.com,1999:blog-7094652.post-71705077407170339352011-05-08T02:21:30.029+01:002011-05-08T02:21:30.029+01:00Small wibble: "Because CmdArgs is impure, GHC...Small wibble: "Because CmdArgs is impure, GHC's optimiser can manipulate the program in ways that change the semantics." -- this isn't quite right, since GHC preserves the semantics of impure programs in e.g. the IO monad.<br /><br />Perhaps more precise would be: "Because CmdArgs has untracked side effects.."Don Stewarthttps://www.blogger.com/profile/08476737262404343154noreply@blogger.com