Skip to content

Commit

Permalink
implement monad function join
Browse files Browse the repository at this point in the history
  • Loading branch information
YarinHeffes authored and stylewarning committed Jan 16, 2025
1 parent b4d093f commit cbc1a93
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/classes.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#:Functor #:map
#:Applicative #:pure #:liftA2
#:Monad #:>>=
#:>>
#:>> #:join
#:MonadFail #:fail
#:Alternative #:alt #:empty
#:Foldable #:fold #:foldr #:mconcat #:mconcatmap
Expand Down Expand Up @@ -212,8 +212,14 @@

(declare >> (Monad :m => (:m :a) -> (:m :b) -> (:m :b)))
(define (>> a b)
"Equivalent to `(>>= a (fn (_) b))`."
(>>= a (fn (_) b)))

(declare join (Monad :m => :m (:m :a) -> :m :a))
(define (join m)
"Equivalent to `(>>= m id)`."
(>>= m (fn (x) x)))

(define-class (Monad :m => MonadFail :m)
(fail (String -> :m :a)))

Expand Down

0 comments on commit cbc1a93

Please sign in to comment.