flatmap   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/tests/core/algebraic_data_types.xtm

Implementation

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


Back to Index

Similar Entries