Re:Haskell version of Norvig's spelling corrector
by codygman on Friday December 19, 2014 @04:24PM
(#8774615)
I used to compose return with a series of pure functions as well, but I found that using liftM seems cleaner.
[ Parent
| on HN ]
Re:Haskell version of Norvig's spelling corrector
by codygman on Friday December 19, 2014 @08:55PM
(#8775581)
example:
nWords = liftM (train . lowerWords . B.unpack) (B.readFile "big.txt")
There was recently a very good article[0] about practically using monads that mentioned using liftM.However whenever using a functor instance is possible it's probably better, since functors can't do as much as monads. I'm not quite sure how much this would help/apply to this small example though.
0: http://softwaresimply.blogspot.com/2014/12/ltmt-part-3-monad...