From 7a62c5d4898bb3a71d0de7570a5c86e12dfe6d25 Mon Sep 17 00:00:00 2001 From: Stephen Diehl Date: Sat, 9 Apr 2016 15:13:13 -0400 Subject: [PATCH] functor module --- protolude.cabal | 1 + src/Debug.hs | 18 +++++++++--------- src/Functor.hs | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 src/Functor.hs diff --git a/protolude.cabal b/protolude.cabal index d69217b4c..56b1d6e82 100644 --- a/protolude.cabal +++ b/protolude.cabal @@ -35,6 +35,7 @@ library Monad Show Unsafe + Functor default-extensions: NoImplicitPrelude diff --git a/src/Debug.hs b/src/Debug.hs index 090351df3..7880373dc 100644 --- a/src/Debug.hs +++ b/src/Debug.hs @@ -1,15 +1,15 @@ {-# LANGUAGE NoImplicitPrelude #-} module Debug ( - undefined - , error - , trace - , traceM - , traceIO - , traceShow - , traceShowM - , notImplemented - ) where + undefined, + error, + trace, + traceM, + traceIO, + traceShow, + traceShowM, + notImplemented, +) where import qualified Prelude as P import qualified Debug.Trace as T diff --git a/src/Functor.hs b/src/Functor.hs new file mode 100644 index 000000000..11addfc7b --- /dev/null +++ b/src/Functor.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module Functor ( + Functor(..), + ($>), + (<$>), + void, +) where + +#if (__GLASGOW_HASKELL__ >= 710) +import Data.Functor ( + Functor(..) + , ($>) + , (<$>) + , void + ) +#else +import Data.Functor ( + Functor(..) + , (<$>) + ) + +($>) :: Functor f => f a -> b -> f b +($>) = flip (<$) + +void :: Functor f => f a -> f () +void x = () <$ x +#endif