shithub: MicroHs

Download patch

ref: 74a051e7af311cda205f4558adf15f9be3159907
parent: c43ac952958cf35d35b0c48715f695feea16d226
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Wed Jan 10 07:39:54 EST 2024

Add runIdentity

--- a/lib/Data/Functor/Identity.hs
+++ b/lib/Data/Functor/Identity.hs
@@ -1,9 +1,11 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
-module Data.Functor.Identity(Identity(..)) where
+module Data.Functor.Identity(Identity(..), runIdentity) where
 import Primitives
 import Control.Applicative
 import Control.Monad
+import Data.Bool
+import Data.Eq
 import Data.Function
 import Data.Functor
 import Data.Int
@@ -11,7 +13,11 @@
 import Text.Show
 
 newtype Identity a = Identity a
+  deriving (Eq, Ord, Show)
 
+runIdentity :: forall a . Identity a -> a
+runIdentity (Identity a) = a
+
 instance Functor Identity where
   fmap f (Identity a) = Identity (f a)
 
@@ -21,6 +27,3 @@
 
 instance Monad Identity where
   Identity a >>= f = f a
-
-instance forall a . (Show a) => Show (Identity a) where
-  showsPrec p (Identity a) = showParen (p >= 11) (showString "Identity " . showsPrec 11 a)
--