mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Define an Applicative instance for Incr.
This commit is contained in:
parent
24cff39c17
commit
d0f9cbbc10
@ -134,6 +134,11 @@ data Incr a
|
||||
| S a
|
||||
deriving (Eq, Foldable, Functor, Ord, Show, Traversable)
|
||||
|
||||
instance Applicative Incr where
|
||||
pure = S
|
||||
Z <*> _ = Z
|
||||
S f <*> a = f <$> a
|
||||
|
||||
match :: (Applicative f, Eq a) => a -> a -> Incr (f a)
|
||||
match x y | x == y = Z
|
||||
| otherwise = S (pure y)
|
||||
|
Loading…
Reference in New Issue
Block a user