Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-monoid": "^2.0.0"
"purescript-monoid": "^2.2.0",
"purescript-prelude": "^2.4.0"
}
}
6 changes: 6 additions & 0 deletions src/Data/Maybe.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import Control.Extend (class Extend)
import Control.MonadZero (class MonadZero)
import Control.Plus (class Plus)

import Data.Eq (class Eq1)
import Data.Functor.Invariant (class Invariant, imapF)
import Data.Monoid (class Monoid)
import Data.Ord (class Ord1)

-- | The `Maybe` type is used to represent optional values and can be seen as
-- | something like a type-safe `null`, where `Nothing` is `null` and `Just x`
Expand Down Expand Up @@ -184,13 +186,17 @@ instance monoidMaybe :: Semigroup a => Monoid (Maybe a) where
-- | type the `Maybe` contains.
derive instance eqMaybe :: Eq a => Eq (Maybe a)

instance eq1Maybe :: Eq1 Maybe where eq1 = eq

-- | The `Ord` instance allows `Maybe` values to be compared with
-- | `compare`, `>`, `>=`, `<` and `<=` whenever there is an `Ord` instance for
-- | the type the `Maybe` contains.
-- |
-- | `Nothing` is considered to be less than any `Just` value.
derive instance ordMaybe :: Ord a => Ord (Maybe a)

instance ord1Maybe :: Ord1 Maybe where compare1 = compare

instance boundedMaybe :: Bounded a => Bounded (Maybe a) where
top = Just top
bottom = Nothing
Expand Down
6 changes: 6 additions & 0 deletions src/Data/Maybe/First.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import Prelude

import Control.Extend (class Extend)

import Data.Eq (class Eq1)
import Data.Functor.Invariant (class Invariant)
import Data.Maybe (Maybe(..))
import Data.Monoid (class Monoid)
import Data.Newtype (class Newtype)
import Data.Ord (class Ord1)

-- | Monoid returning the first (left-most) non-`Nothing` value.
-- |
Expand All @@ -23,8 +25,12 @@ derive instance newtypeFirst :: Newtype (First a) _

derive newtype instance eqFirst :: (Eq a) => Eq (First a)

derive newtype instance eq1First :: Eq1 First

derive newtype instance ordFirst :: (Ord a) => Ord (First a)

derive newtype instance ord1First :: Ord1 First

derive newtype instance boundedFirst :: (Bounded a) => Bounded (First a)

derive newtype instance functorFirst :: Functor First
Expand Down
6 changes: 6 additions & 0 deletions src/Data/Maybe/Last.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import Prelude

import Control.Extend (class Extend)

import Data.Eq (class Eq1)
import Data.Functor.Invariant (class Invariant)
import Data.Maybe (Maybe(..))
import Data.Monoid (class Monoid)
import Data.Newtype (class Newtype)
import Data.Ord (class Ord1)

-- | Monoid returning the last (right-most) non-`Nothing` value.
-- |
Expand All @@ -23,8 +25,12 @@ derive instance newtypeLast :: Newtype (Last a) _

derive newtype instance eqLast :: (Eq a) => Eq (Last a)

derive newtype instance eq1Last :: Eq1 Last

derive newtype instance ordLast :: (Ord a) => Ord (Last a)

derive newtype instance ord1Last :: Ord1 Last

derive newtype instance boundedLast :: (Bounded a) => Bounded (Last a)

derive newtype instance functorLast :: Functor Last
Expand Down