Skip to content

Commit

Permalink
Merge pull request #3 from i-am-tom/master
Browse files Browse the repository at this point in the history
Add Monoid instance for Effect
  • Loading branch information
garyb authored Apr 19, 2018
2 parents a152300 + 1a94263 commit d43d728
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"package.json"
],
"dependencies": {
"purescript-prelude": "^3.0.0"
"purescript-prelude": "^3.0.0",
"purescript-monoid": "^3.3.0"
}
}
10 changes: 9 additions & 1 deletion src/Effect.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ module Effect
) where

import Control.Applicative (class Applicative, liftA1)
import Control.Apply (class Apply)
import Control.Apply (class Apply, lift2)
import Control.Bind (class Bind)
import Control.Monad (class Monad, ap)

import Data.Functor (class Functor)
import Data.Monoid (class Monoid, mempty)
import Data.Semigroup (class Semigroup, append)
import Data.Unit (Unit)

-- | The `Effect` type constructor is used to represent _native_ effects.
Expand All @@ -28,6 +30,12 @@ instance applyEffect :: Apply Effect where
instance applicativeEffect :: Applicative Effect where
pure = pureE

instance semigroupEffect :: Semigroup a => Semigroup (Effect a) where
append = lift2 append

instance monoidEffect :: Monoid a => Monoid (Effect a) where
mempty = pureE mempty

foreign import pureE :: forall a. a -> Effect a

instance bindEffect :: Bind Effect where
Expand Down

0 comments on commit d43d728

Please sign in to comment.