Is (sequence .) . flip fmap
the same as forM
? I ask here because pointfree.io seems not to say the same...
Asked
Active
Viewed 89 times
1

Enlico
- 23,259
- 6
- 48
- 102
-
1I believe they are equivalent. AFAIK, pointfree.io does not guarantee the shortest option, or in general knows about all the library helpers. – chi Feb 14 '21 at 17:20
-
1Exactly; `(sequence .) . flip fmap` is *already* in point-free form. It's `pointfree.io`, not `minimalexpression.io`. – chepner Feb 15 '21 at 14:08
-
Yeah, I knew it was point free already, but somehow I never tried putting already pointfree expression there, so I got convinced that it would shorten to the minimum. I don't even know if it's possible. – Enlico Feb 15 '21 at 14:13
1 Answers
5
Yes, it is:
(sequence .) . flip fmap
(sequence .) . (\u f -> fmap f u)
\u -> sequence . (\f -> fmap f u)
\u f -> sequence (fmap f u)
\u f -> mapM f u
flip mapM
forM
As chi notes, presumably it's just that pointfree.io doesn't know about forM
.

duplode
- 33,731
- 7
- 79
- 150