1
1
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:
Rob Rix 2019-07-02 09:29:35 -04:00
parent 24cff39c17
commit d0f9cbbc10
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -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)