Skip to content

Commit

Permalink
Merge pull request #37 from MonoidMusician/monadzero
Browse files Browse the repository at this point in the history
Add MonadZero instances
  • Loading branch information
garyb authored Apr 7, 2018
2 parents 6c3cee0 + 0a8095d commit b7c9ca9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/Data/Maybe/First.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Data.Maybe.First where
import Prelude

import Control.Extend (class Extend)

import Control.MonadZero (class MonadZero, class Alternative, class Plus, class Alt)
import Data.Eq (class Eq1)
import Data.Functor.Invariant (class Invariant)
import Data.Maybe (Maybe(..))
import Data.Monoid (class Monoid)
import Data.Monoid (class Monoid, mempty)
import Data.Newtype (class Newtype)
import Data.Ord (class Ord1)

Expand Down Expand Up @@ -56,3 +56,13 @@ instance semigroupFirst :: Semigroup (First a) where

instance monoidFirst :: Monoid (First a) where
mempty = First Nothing

instance altFirst :: Alt First where
alt = append

instance plusFirst :: Plus First where
empty = mempty

instance alternativeFirst :: Alternative First

instance monadZeroFirst :: MonadZero First
14 changes: 12 additions & 2 deletions src/Data/Maybe/Last.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Data.Maybe.Last where
import Prelude

import Control.Extend (class Extend)

import Control.MonadZero (class MonadZero, class Alternative, class Plus, class Alt)
import Data.Eq (class Eq1)
import Data.Functor.Invariant (class Invariant)
import Data.Maybe (Maybe(..))
import Data.Monoid (class Monoid)
import Data.Monoid (class Monoid, mempty)
import Data.Newtype (class Newtype)
import Data.Ord (class Ord1)

Expand Down Expand Up @@ -56,3 +56,13 @@ instance semigroupLast :: Semigroup (Last a) where

instance monoidLast :: Monoid (Last a) where
mempty = Last Nothing

instance altLast :: Alt Last where
alt = append

instance plusLast :: Plus Last where
empty = mempty

instance alternativeLast :: Alternative Last

instance monadZeroLast :: MonadZero Last

0 comments on commit b7c9ca9

Please sign in to comment.