[Haskell-beginners] getopt
Magnus Therning
magnus at therning.org
Thu Aug 5 16:12:12 EDT 2010
On 05/08/10 20:18, Gaius Hammond wrote:
> Hi all,
>
>
> I have used GetOpt in Python and Ocaml so I am reasonably familiar with
> it, and I have been studying the technique here:
>
>
> http://www.haskell.org/haskellwiki/High-level_option_handling_with_GetOpt
>
>
> Can anyone explain to me what is actually happening here:
>
>
> opts <- foldl (>>=) (return startOptions) actions
>
> let Options { optVerbose = verbose
> , optInput = input
> , optOutput = output } = opts
> input >>= output
>
> I understand the fold is evaluating everything in the actions list
> overlaying them onto the startOptions record, then getting these out of
> IO and into the opts record - but where are "verbose", "input" and
> "output" coming from? Are they just aliases?
It's an example of pattern matching, it "picks apart" 'opts'. So, yes,
they are aliases for the values of the "members" of 'opts'.
/M
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/beginners/attachments/20100805/3ac51537/signature.bin
More information about the Beginners
mailing list