@@ -2,9 +2,9 @@ module Data.Maybe.Last where
2
2
3
3
import Prelude
4
4
5
- import Control.Extend (class Extend , extend )
5
+ import Control.Extend (class Extend )
6
6
7
- import Data.Functor.Invariant (class Invariant , imapF )
7
+ import Data.Functor.Invariant (class Invariant )
8
8
import Data.Maybe (Maybe (..))
9
9
import Data.Monoid (class Monoid )
10
10
import Data.Newtype (class Newtype )
@@ -21,31 +21,25 @@ newtype Last a = Last (Maybe a)
21
21
22
22
derive instance newtypeLast :: Newtype (Last a ) _
23
23
24
- derive newtype instance eqLast :: Eq a => Eq (Last a )
24
+ derive newtype instance eqLast :: ( Eq a ) => Eq (Last a )
25
25
26
- derive newtype instance ordLast :: Ord a => Ord (Last a )
26
+ derive newtype instance ordLast :: ( Ord a ) => Ord (Last a )
27
27
28
- derive newtype instance boundedLast :: Bounded a => Bounded (Last a )
28
+ derive newtype instance boundedLast :: ( Bounded a ) => Bounded (Last a )
29
29
30
- instance functorLast :: Functor Last where
31
- map f (Last x) = Last (f <$> x)
30
+ derive newtype instance functorLast :: Functor Last
32
31
33
- instance invariantLast :: Invariant Last where
34
- imap = imapF
32
+ derive newtype instance invariantLast :: Invariant Last
35
33
36
- instance applyLast :: Apply Last where
37
- apply (Last f) (Last x) = Last (f <*> x)
34
+ derive newtype instance applyLast :: Apply Last
38
35
39
- instance applicativeLast :: Applicative Last where
40
- pure = Last <<< pure
36
+ derive newtype instance applicativeLast :: Applicative Last
41
37
42
- instance bindLast :: Bind Last where
43
- bind (Last x) f = Last (x >>= \y -> case f y of Last ma -> ma)
38
+ derive newtype instance bindLast :: Bind Last
44
39
45
- instance monadLast :: Monad Last
40
+ derive newtype instance monadLast :: Monad Last
46
41
47
- instance extendLast :: Extend Last where
48
- extend f (Last x) = Last (extend (f <<< Last ) x)
42
+ derive newtype instance extendLast :: Extend Last
49
43
50
44
instance showLast :: Show a => Show (Last a ) where
51
45
show (Last a) = " (Last " <> show a <> " )"
0 commit comments