aboutsummaryrefslogtreecommitdiff
path: root/Haskell-book/17/Identity.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Haskell-book/17/Identity.hs')
-rw-r--r--Haskell-book/17/Identity.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Haskell-book/17/Identity.hs b/Haskell-book/17/Identity.hs
new file mode 100644
index 0000000..6b5f9a9
--- /dev/null
+++ b/Haskell-book/17/Identity.hs
@@ -0,0 +1,9 @@
+newtype Identity a = Identity a
+ deriving (Eq, Show, Ord)
+
+instance Functor Identity where
+ fmap f (Identity x) = Identity $ f x
+
+instance Applicative Identity where
+ pure x = Identity x
+ (Identity f) <*> (Identity y) = Identity $ f y