ref: c43ac952958cf35d35b0c48715f695feea16d226
parent: 40aea484f78df68538144ab19fd8ebde15bda5b7
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Wed Jan 10 07:39:35 EST 2024
Add Const
--- /dev/null
+++ b/lib/Data/Functor/Const.hs
@@ -1,0 +1,28 @@
+-- Copyright 2023 Lennart Augustsson
+-- See LICENSE file for full license.
+module Data.Functor.Const(Const(..), getConst) where
+import Primitives
+import Control.Applicative
+import Control.Monad
+import Data.Bool
+import Data.Eq
+import Data.Function
+import Data.Functor
+import Data.Int
+import Data.Monoid
+import Data.Ord
+import Text.Show
+
+type Const :: forall k . Type -> k -> Type
+newtype Const a b = Const a
+ deriving (Eq, Ord, Show)
+
+getConst :: forall a b . Const a b -> a
+getConst (Const a) = a
+
+instance forall a . Functor (Const a) where
+ fmap _ (Const a) = Const a
+
+instance forall m . Monoid m => Applicative (Const m) where
+ pure _ = Const mempty
+ Const a <*> Const b = Const (a `mappend` b)
--
⑨