Re:Confessions of a Ruby Developer Whose Heart was Stolen by...
by pja on Thursday June 13, 2013 @06:34AM
(#5873274)
oo. I'd forgotten about fix.
cycleM = fix . mplus
gives a nice generic version that works on Lists & Sequences but falls afoul of the monomorphism restriction, so it needs a type: cycleM :: (MonadPlus m) => m a -> m a
cycleM = fix . mplus
That's one reason I still prefer Haskell even though Scala is easier to sneak into enterprise projects thanks to JVM. Not to mention that Haskell gives stronger static guarantees and has a more sophisticated type inference system.