Last active
January 10, 2017 15:08
-
-
Save ygrenzinger/0416472fcab5f3069fdc8e3ab4335d2b to your computer and use it in GitHub Desktop.
Constant Applicative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Constant a b = Constant { getConstant :: a } deriving (Eq, Ord, Show) | |
instance Functor (Constant a) where | |
fmap _ (Constant a) = Constant a | |
instance Monoid a => Applicative (Constant a) where | |
pure x = Constant mempty | |
(<*>) (Constant a) (Constant b) = Constant (a <> b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment