flatmap   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/base/prelude.xtm

Implementation

;; it's more convenient to have the function in last arg position
(bind-func flatmap:[Option{!b}*,Option{!a}*,[Option{!b}*,!a]*]*
  (lambda (M f)
    ;; (join (fmap f M)))) ;; alternate using join & fmap
    (Some$ M (x) (f x) (None))))


Back to Index

Similar Entries