Skip to content

Commit

Permalink
Merge pull request #16 from stefan-hoeck/handler_monoid
Browse files Browse the repository at this point in the history
[ new ] monoid and semigroup for Handler and Cmd
  • Loading branch information
stefan-hoeck committed Jul 21, 2023
2 parents 9785242 + 91c37d8 commit e3f55ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Web/MVC/Cmd.idr
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ export %inline
inject : Has e es => Handler (HSum es) -> Handler e
inject (H h) = H (h . inject)

export
Semigroup (Handler e) where
H f <+> H g = H $ \v => f v >> g v

export
Monoid (Handler e) where
neutral = H $ \_ => pure ()

--------------------------------------------------------------------------------
-- Registering Events
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -152,6 +160,14 @@ export %inline
Functor Cmd where
map f (C run) = C $ run @{contramap f %search}

export
Semigroup (Cmd e) where
C f <+> C g = C $ f >> g

export
Monoid (Cmd e) where
neutral = C $ pure ()

public export
0 Cmds : Type -> Type
Cmds = List . Cmd
Expand Down

0 comments on commit e3f55ba

Please sign in to comment.