Skip to content

Add IxMonad and Monad instances for Render #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/React/Basic/Hooks/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Prelude hiding (bind)
import Control.Applicative.Indexed (class IxApplicative)
import Control.Apply.Indexed (class IxApply)
import Control.Bind.Indexed (class IxBind, ibind)
import Control.Monad.Indexed (class IxMonad)
import Data.Functor.Indexed (class IxFunctor)
import Data.Newtype (class Newtype)
import Effect (Effect)
Expand Down Expand Up @@ -148,6 +149,8 @@ instance ixApplicativeRender :: IxApplicative Render where
instance ixBindRender :: IxBind Render where
ibind (Render m) f = Render (Prelude.bind m \a -> case f a of Render b -> b)

instance ixMonadRender :: IxMonad Render

-- | Exported for use with qualified-do syntax
bind :: forall a b x y z m. IxBind m => m x y a -> (a -> m y z b) -> m x z b
bind = ibind
Expand All @@ -168,6 +171,8 @@ instance applicativeRender :: TypeEquals x y => Applicative (Render x y) where
instance bindRender :: TypeEquals x y => Bind (Render x y) where
bind (Render m) f = Render (Prelude.bind m \a -> case f a of Render b -> b)

instance monadRender :: TypeEquals x y => Monad (Render x y)

instance semigroupRender :: (TypeEquals x y, Semigroup a) => Semigroup (Render x y a) where
append (Render a) (Render b) = Render (append a b)

Expand Down