[Haskell-cafe] Code critique - Was [Maybe Int] sans Nothings

michael rice nowgate at yahoo.com
Wed May 25 13:11:08 CEST 2011


Yes, very nice. Thanks.
Michael

--- On Wed, 5/25/11, Henning Thielemann <schlepptop at henning-thielemann.de> wrote:

From: Henning Thielemann <schlepptop at henning-thielemann.de>
Subject: Re: [Haskell-cafe] Code critique - Was [Maybe Int] sans Nothings
To: "michael rice" <nowgate at yahoo.com>
Cc: "Haskell Cafe" <haskell-cafe at haskell.org>
Date: Wednesday, May 25, 2011, 3:41 AM

Alexander Solla schrieb:

>     buildMap :: GeneratorState1 (Map Prefix [String])
>     buildMap = do (mp,(pfx1,pfx2),words) <- get
>                   if (Prelude.null words)
>                     then {- No more words. Return final map (adding
>     non_word for final prefix). -}
>                       return (insertWithKey' f (pfx1,pfx2) [non_word] mp)
>                     else do {- Add word to map at prefix & continue. -}
>                       put (insertWithKey' f (pfx1,pfx2) [head words] mp,
>     (pfx2,(head words)), tail words)
>                       buildMap
> 
>>>> I'm not a fan of explicit if-then-else's, but my preferred

case words of
   [] -> {- no more words -} ...
   w:ws -> ...

would work perfectly.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110525/24341209/attachment.htm>


More information about the Haskell-Cafe mailing list