[Haskell-beginners] Re: Simplifying a 'split' function
es at ertes.de
Thu Apr 30 16:11:52 EDT 2009
"Brandon S. Allbery KF8NH" <allbery at ece.cmu.edu> wrote:
> >> How about map pure. I do like the robot monkey though :)
> > What is 'map pure'?
> It uses the applicative functor (Control.Applicative) instance for
> lists, just as "fmap return" uses the monad instance. Both work out
> to the same thing.
In fact, I'd choose a combination of both,
split = fmap pure
which seems to be most elegant to me. It's more general than both of
them. I just took 'return' instead of 'pure', because you don't need
any extra modules for that.
nightmare = unsafePerformIO (getWrongWife >>= sex)
More information about the Beginners