/
Indexed.purs
34 lines (28 loc) · 1.14 KB
/
Indexed.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Control.Monad.Indexed
( class IxMonad
, iap
, iwhenM
, iunlessM
, module Control.Applicative.Indexed
, module Control.Apply.Indexed
, module Control.Bind.Indexed
, module Data.Functor.Indexed
) where
import Prelude
import Control.Applicative.Indexed (class IxApplicative, ipure, iwhen, iunless)
import Control.Apply.Indexed (class IxApply, iapply, iapplyFirst, iapplySecond, (:*>), (<*:))
import Control.Bind.Indexed (class IxBind, ibind, (:>>=), ibindFlipped, (=<<:), composeiKleisli, (:>=>), composeiKleisliFlipped, (<=<:))
import Data.Functor.Indexed (class IxFunctor, imap, ivoid, ivoidLeft, ivoidRight, (:$>), (<$:))
class IxMonad ∷ ∀ ix. (ix → ix → Type → Type) → Constraint
class (IxApplicative m, IxBind m) ⇐ IxMonad m
iap ∷ ∀ m a b x y z. IxMonad m ⇒ m x y (a → b) → m y z a → m x z b
iap f a = do
f' ← f
a' ← a
ipure (f' a')
where
bind = ibind
iwhenM ∷ ∀ m x y. IxMonad m ⇒ m x y Boolean → m y y Unit → m x y Unit
iwhenM mb m = mb :>>= \b → iwhen b m
iunlessM ∷ ∀ m x y. IxMonad m ⇒ m x y Boolean → m y y Unit → m x y Unit
iunlessM mb m = mb :>>= \b → iunless b m