extensible-effects 1.9.1.0 → 1.9.2.2
raw patch · 24 files changed
+109/−52 lines, 24 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Eff.Choose: instance Functor Choose
- Control.Eff.Choose: instance Typeable Choose
- Control.Eff.Coroutine: instance Functor (Yield a)
- Control.Eff.Coroutine: instance Typeable Yield
- Control.Eff.Cut: instance Typeable CutFalse
- Control.Eff.Exception: instance Functor (Exc e)
- Control.Eff.Exception: instance Typeable Exc
- Control.Eff.Fresh: instance Functor (Fresh i)
- Control.Eff.Fresh: instance Typeable Fresh
- Control.Eff.Lift: instance (MonadBase b m, Typeable m, SetMember Lift (Lift m) r) => MonadBase b (Eff r)
- Control.Eff.Lift: instance (Typeable m, MonadIO m, SetMember Lift (Lift m) r) => MonadIO (Eff r)
- Control.Eff.Lift: instance Functor (Lift m)
- Control.Eff.Lift: instance Typeable Lift
- Control.Eff.Operational: instance Functor (Program instr)
- Control.Eff.Operational: instance Typeable Program
- Control.Eff.Operational.Example: instance Typeable Jail
- Control.Eff.Reader.Lazy: instance Functor (Reader e)
- Control.Eff.Reader.Lazy: instance Typeable Reader
- Control.Eff.Reader.Strict: instance Functor (Reader e)
- Control.Eff.Reader.Strict: instance Typeable Reader
- Control.Eff.State.Lazy: instance Functor (State s)
- Control.Eff.State.Lazy: instance Typeable State
- Control.Eff.State.Strict: instance Functor (State s)
- Control.Eff.State.Strict: instance Typeable State
- Control.Eff.Trace: instance Functor Trace
- Control.Eff.Trace: instance Typeable Trace
- Control.Eff.Writer.Lazy: instance Functor (Writer w)
- Control.Eff.Writer.Lazy: instance Typeable Writer
- Control.Eff.Writer.Strict: instance Functor (Writer w)
- Control.Eff.Writer.Strict: instance Typeable Writer
- Control.Monad.Free.Reflection: instance Functor f => Applicative (Free f)
- Control.Monad.Free.Reflection: instance Functor f => Functor (Free f)
- Control.Monad.Free.Reflection: instance Functor f => Monad (Free f)
- Control.Monad.Free.Reflection: instance Typeable Free
- Control.Monad.Free.Reflection: instance Typeable FreeView
- Data.OpenUnion: instance MemberU set t r => SetMember set t r
- Data.OpenUnion: instance Typeable Id
+ Control.Eff.Choose: instance [safe] Functor Choose
+ Control.Eff.Choose: instance [safe] Typeable Choose
+ Control.Eff.Coroutine: instance [safe] Functor (Yield a)
+ Control.Eff.Coroutine: instance [safe] Typeable Yield
+ Control.Eff.Cut: instance [safe] Typeable CutFalse
+ Control.Eff.Exception: instance [safe] Functor (Exc e)
+ Control.Eff.Exception: instance [safe] Typeable Exc
+ Control.Eff.Fresh: instance [safe] Functor (Fresh i)
+ Control.Eff.Fresh: instance [safe] Typeable Fresh
+ Control.Eff.Lift: instance [safe] (MonadBase b m, Typeable m, SetMember Lift (Lift m) r) => MonadBase b (Eff r)
+ Control.Eff.Lift: instance [safe] (Typeable m, MonadIO m, SetMember Lift (Lift m) r) => MonadIO (Eff r)
+ Control.Eff.Lift: instance [safe] Functor (Lift m)
+ Control.Eff.Lift: instance [safe] Typeable Lift
+ Control.Eff.Operational: instance [safe] Functor (Program instr)
+ Control.Eff.Operational: instance [safe] Typeable Program
+ Control.Eff.Operational.Example: instance [safe] Typeable Jail
+ Control.Eff.Reader.Lazy: instance [safe] Functor (Reader e)
+ Control.Eff.Reader.Lazy: instance [safe] Typeable Reader
+ Control.Eff.Reader.Strict: instance [safe] Functor (Reader e)
+ Control.Eff.Reader.Strict: instance [safe] Typeable Reader
+ Control.Eff.State.Lazy: instance [safe] Functor (State s)
+ Control.Eff.State.Lazy: instance [safe] Typeable State
+ Control.Eff.State.Strict: instance [safe] Functor (State s)
+ Control.Eff.State.Strict: instance [safe] Typeable State
+ Control.Eff.Trace: instance [safe] Functor Trace
+ Control.Eff.Trace: instance [safe] Typeable Trace
+ Control.Eff.Writer.Lazy: instance [safe] Functor (Writer w)
+ Control.Eff.Writer.Lazy: instance [safe] Typeable Writer
+ Control.Eff.Writer.Strict: instance [safe] Functor (Writer w)
+ Control.Eff.Writer.Strict: instance [safe] Typeable Writer
+ Control.Monad.Free.Reflection: instance [safe] Functor f => Applicative (Free f)
+ Control.Monad.Free.Reflection: instance [safe] Functor f => Functor (Free f)
+ Control.Monad.Free.Reflection: instance [safe] Functor f => Monad (Free f)
+ Control.Monad.Free.Reflection: instance [safe] Typeable Free
+ Control.Monad.Free.Reflection: instance [safe] Typeable FreeView
+ Data.OpenUnion: instance [safe] MemberU set t r => SetMember set t r
+ Data.OpenUnion: instance [safe] Typeable Id
+ Data.OpenUnion.Imports: (*>) :: Applicative f => f a -> f b -> f b
+ Data.OpenUnion.Imports: (<*) :: Applicative f => f a -> f b -> f a
+ Data.OpenUnion.Imports: (<*>) :: Applicative f => f (a -> b) -> f a -> f b
+ Data.OpenUnion.Imports: class Functor f => Applicative (f :: * -> *)
+ Data.OpenUnion.Imports: pure :: Applicative f => a -> f a
Files
- README.md +19/−10
- extensible-effects.cabal +16/−5
- src/Control/Eff.hs +1/−0
- src/Control/Eff/Choose.hs +3/−3
- src/Control/Eff/Coroutine.hs +1/−0
- src/Control/Eff/Cut.hs +7/−1
- src/Control/Eff/Exception.hs +1/−0
- src/Control/Eff/Fresh.hs +2/−1
- src/Control/Eff/Lift.hs +3/−0
- src/Control/Eff/Operational.hs +3/−0
- src/Control/Eff/Operational/Example.hs +1/−0
- src/Control/Eff/Reader/Lazy.hs +3/−3
- src/Control/Eff/Reader/Strict.hs +3/−3
- src/Control/Eff/State/Lazy.hs +1/−0
- src/Control/Eff/State/Strict.hs +1/−0
- src/Control/Eff/Trace.hs +1/−0
- src/Control/Eff/Writer/Lazy.hs +4/−3
- src/Control/Eff/Writer/Strict.hs +4/−3
- src/Control/Monad/Free/Reflection.hs +3/−2
- src/Data/OpenUnion.hs +5/−9
- src/Data/OpenUnion/Imports.hs +15/−0
- src/Data/OpenUnion/Internal/Base.hs +1/−0
- src/Data/OpenUnion/Internal/OpenUnion1.hs +1/−0
- src/Data/OpenUnion/Internal/OpenUnion2.hs +10/−9
README.md view
@@ -14,21 +14,30 @@ ## Disadvantages ### For GHC version 7.8 and upwards- * Common functions can't be grouped using typeclasses, e.g.- the `ask` and `getState` functions can't be grouped with some+ * The extensibility comes at the cost of some ambiguity. Note, however, that+ the extensibility can be traded back, but that detracts from some of the+ advantages. For details see section 4.1 in the+ [paper](http://okmij.org/ftp/Haskell/extensible/exteff.pdf). This issue+ manifests itself in a few ways:+ * Common functions can't be grouped using typeclasses, e.g.+ the `ask` and `getState` functions can't be grouped with some - class Get t a where- ask :: Member (t a) r => Eff r a+ class Get t a where+ ask :: Member (t a) r => Eff r a - `ask` is inherently ambiguous, since the type signature only provides- a constraint on `t`, and nothing more. To specify fully, a parameter- involving the type `t` would need to be added, which would defeat the point- of having the grouping in the first place.+ `ask` is inherently ambiguous, since the type signature only provides+ a constraint on `t`, and nothing more. To specify fully, a parameter+ involving the type `t` would need to be added, which would defeat the+ point of having the grouping in the first place.+ * Code requires greater number of type annotations. For details see+ [#31](https://github.com/suhailshergill/extensible-effects/issues/31). * Requires a `Typeable` instance on the return type. This is no longer a limitation on GHC versions 7.8 and above.- * fixed by https://github.com/suhailshergill/extensible-effects/issues/38+ * fixed by+ [#38](https://github.com/suhailshergill/extensible-effects/issues/38). ### For GHC versions prior to 7.8 * Neither `Eff` nor `(:>)` has a `Typeable` instance, and can thus often not be used as a return type (e.g. `State` type) for other `Eff`s. - * fixed by https://github.com/suhailshergill/extensible-effects/issues/38+ * fixed by+ [#38](https://github.com/suhailshergill/extensible-effects/issues/38).
extensible-effects.cabal view
@@ -6,7 +6,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 1.9.1.0+version: 1.9.2.2 -- A short (one-line) description of the package. synopsis: An Alternative to Monad Transformers@@ -23,7 +23,7 @@ stability: Experimental -- URL for the project homepage or repository.-homepage: https://github.com/RobotGymnast/extensible-effects+homepage: https://github.com/suhailshergill/extensible-effects -- The license under which the package is released. license: MIT@@ -43,7 +43,7 @@ category: Control, Effect -tested-with: GHC==7.8.3, GHC==7.6.3+tested-with: GHC==7.10.1, GHC==7.8.4, GHC==7.6.3 build-type: Simple @@ -54,6 +54,9 @@ -- Constraint on the version of Cabal needed to build this package. cabal-version: >=1.10 +flag lib-Werror+ default: False+ manual: True library ghc-options: -Wall@@ -76,15 +79,18 @@ Control.Eff.Operational.Example Control.Monad.Free.Reflection Data.OpenUnion+ Data.OpenUnion.Imports -- Modules included in this library but not exported. other-modules: Data.OpenUnion.Internal.Base if impl(ghc >= 7.8.1) other-modules: Data.OpenUnion.Internal.OpenUnion2+ default-extensions: Safe else other-modules: Data.OpenUnion.Internal.OpenUnion1+ other-extensions: Safe+ , Trustworthy - default-extensions: Trustworthy -- LANGUAGE extensions used by modules in this package. other-extensions: BangPatterns , CPP@@ -124,6 +130,11 @@ -- Base language which the package is written in. default-language: Haskell2010 + -- TODO: uncomment when https://github.com/haskell/cabal/issues/2527 is+ -- resolved+ -- if flag(lib-Werror)+ -- ghc-options: -Werror+ test-suite extensible-effects-tests type: exitcode-stdio-1.0 main-is: Test.hs@@ -145,4 +156,4 @@ source-repository head type: git- location: https://github.com/RobotGymnast/extensible-effects.git+ location: https://github.com/suhailshergill/extensible-effects.git
src/Control/Eff.hs view
@@ -9,6 +9,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} -- | Original work available at <http://okmij.org/ftp/Haskell/extensible/Eff.hs>. -- This module implements extensible effects as an alternative to monad transformers,
src/Control/Eff/Choose.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE Safe #-} -- | Nondeterministic choice effect module Control.Eff.Choose( Choose (..) , choose@@ -10,9 +11,8 @@ , mplus' ) where -import Control.Applicative ((<$>))-import Control.Monad (join) import Data.Typeable+import Control.Monad (join) import Control.Eff @@ -47,4 +47,4 @@ handle :: [t] -> (t -> Eff (Choose :> r) a) -> Eff r [a] handle [] _ = return [] handle [x] k = loop (k x)- handle lst k = concat <$> mapM (loop . k) lst+ handle lst k = concat `fmap` mapM (loop . k) lst
src/Control/Eff/Coroutine.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Coroutines implemented with extensible effects module Control.Eff.Coroutine( Yield (..) , yield
src/Control/Eff/Cut.hs view
@@ -1,7 +1,13 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ScopedTypeVariables #-}+#if __GLASGOW_HASKELL_ >= 708+{-# LANGUAGE TypeFamilies #-}+#endif+{-# LANGUAGE Safe #-} -- | An example of non-trivial interaction of effects, handling of two -- effects together -- Non-determinism with control (cut)@@ -65,7 +71,7 @@ -- of its argument computation. When it encounteres a cutfalse request, -- it discards the remaining choicepoints. -- It completely handles CutFalse effects but not non-determinism.-call :: Member Choose r => Eff (Exc CutFalse :> r) a -> Eff r a+call :: forall r a . Member Choose r => Eff (Exc CutFalse :> r) a -> Eff r a call = loop [] where loop jq = freeMap (\x -> return x `mplus'` next jq) -- (C2)
src/Control/Eff/Exception.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} -- | Exception-producing and exception-handling effects module Control.Eff.Exception( Exc (..) , Fail
src/Control/Eff/Fresh.hs view
@@ -1,8 +1,9 @@ {-# LANGUAGE TypeOperators #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Create unique Enumerable values. module Control.Eff.Fresh( Fresh (..) , fresh
src/Control/Eff/Lift.hs view
@@ -6,6 +6,9 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ < 708+{-# LANGUAGE Trustworthy #-}+#endif {-# LANGUAGE DeriveDataTypeable #-} {-# OPTIONS -fno-warn-orphans #-} -- | Lifting primitive Monad types to effectful computations.
src/Control/Eff/Operational.hs view
@@ -6,6 +6,9 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}+#if __GLASGOW_HASKELL__ < 708+{-# LANGUAGE Trustworthy #-}+#endif -- | Operational Monad (<https://wiki.haskell.org/Operational>) implemented with -- extensible effects.
src/Control/Eff/Operational/Example.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} module Control.Eff.Operational.Example where
src/Control/Eff/Reader/Lazy.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Lazy read-only state module Control.Eff.Reader.Lazy( Reader (..) , ask@@ -11,7 +12,6 @@ , runReader ) where -import Control.Applicative ((<$>)) import Data.Typeable import Control.Eff@@ -32,7 +32,7 @@ -> Eff r a -> Eff r a local f m = do- e <- f <$> ask+ e <- f `fmap` ask let loop = freeMap return (\u -> interpose u loop (\(Reader k) -> loop (k e)))@@ -40,7 +40,7 @@ -- | Request the environment value using a transformation function. reader :: (Typeable e, Member (Reader e) r) => (e -> a) -> Eff r a-reader f = f <$> ask+reader f = f `fmap` ask -- | The handler of Reader requests. The return type shows that -- all Reader requests are fully handled.
src/Control/Eff/Reader/Strict.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Strict read-only state module Control.Eff.Reader.Strict( Reader (..) , ask@@ -12,7 +13,6 @@ , runReader ) where -import Control.Applicative ((<$>)) import Data.Typeable import Control.Eff@@ -33,7 +33,7 @@ -> Eff r a -> Eff r a local f m = do- e <- f <$> ask+ e <- f `fmap` ask let loop = freeMap return (\u -> interpose u loop (\(Reader k) -> loop (k e)))@@ -41,7 +41,7 @@ -- | Request the environment value using a transformation function. reader :: (Typeable e, Member (Reader e) r) => (e -> a) -> Eff r a-reader f = f <$> ask+reader f = f `fmap` ask -- | The handler of Reader requests. The return type shows that -- all Reader requests are fully handled.
src/Control/Eff/State/Lazy.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Lazy state effect module Control.Eff.State.Lazy( State (..) , get
src/Control/Eff/State/Strict.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Strict state effect -- -- Example: implementing `Control.Eff.Fresh`
src/Control/Eff/Trace.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | A Trace effect for debugging module Control.Eff.Trace( Trace (..) , trace
src/Control/Eff/Writer/Lazy.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Lazy write-only state. module Control.Eff.Writer.Lazy( Writer (..) , tell@@ -13,9 +14,9 @@ , runMonoidWriter ) where -import Control.Applicative ((<$>), (<|>))-import Data.Monoid import Data.Typeable+import Control.Applicative ((<|>))+import Data.Monoid import Control.Eff @@ -45,7 +46,7 @@ loop = freeMap (\x -> return (b, x)) (\u -> handleRelay u loop- $ \(Writer w v) -> first (accum w) <$> loop v)+ $ \(Writer w v) -> first (accum w) `fmap` loop v) -- | Handle Writer requests by taking the first value provided. runFirstWriter :: Typeable w => Eff (Writer w :> r) a -> Eff r (Maybe w, a)
src/Control/Eff/Writer/Strict.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-} -- | Strict write-only state. module Control.Eff.Writer.Strict( Writer (..) , tell@@ -14,9 +15,9 @@ , runMonoidWriter ) where -import Control.Applicative ((<$>), (<|>))-import Data.Monoid import Data.Typeable+import Control.Applicative ((<|>))+import Data.Monoid import Control.Eff @@ -46,7 +47,7 @@ loop = freeMap (\x -> return (b, x)) (\u -> handleRelay u loop- $ \(Writer w v) -> first (accum w) <$> loop v)+ $ \(Writer w v) -> first (accum w) `fmap` loop v) -- | Handle Writer requests by taking the first value provided. runFirstWriter :: Typeable w => Eff (Writer w :> r) a -> Eff r (Maybe w, a)
src/Control/Monad/Free/Reflection.hs view
@@ -4,6 +4,7 @@ #if __GLASGOW_HASKELL__ >= 708 {-# LANGUAGE AutoDeriveTypeable #-} #endif+{-# LANGUAGE Safe #-} module Control.Monad.Free.Reflection( Free@@ -16,7 +17,7 @@ ) where import Control.Arrow (Kleisli (..))-import Control.Applicative+import qualified Data.OpenUnion.Imports as P import Control.Monad import Data.TASequence import Data.TASequence.FastCatQueue (FastTCQueue)@@ -54,7 +55,7 @@ instance Functor f => Functor (Free f) where fmap = liftM-instance Functor f => Applicative (Free f) where+instance Functor f => P.Applicative (Free f) where pure = return (<*>) = ap instance Functor f => Monad (Free f) where
src/Data/OpenUnion.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} -- Only for SetMember below, when emulating Monad Transformers {-# LANGUAGE FunctionalDependencies, UndecidableInstances #-}@@ -34,13 +35,8 @@ , weaken ) where -import Control.Applicative ((<$>))+import Data.OpenUnion.Imports import Data.Typeable-#if __GLASGOW_HASKELL__ >= 708-import Data.OpenUnion.Internal.OpenUnion2-#else-import Data.OpenUnion.Internal.OpenUnion1-#endif infixl 4 <?> @@ -77,19 +73,19 @@ {-# INLINE prj #-} -- | Try extracting the contents of a Union as a given type. prj :: (Typeable1 t, Member t r) => Union r v -> Maybe (t v)-prj (Union v) = runId <$> gcast1 (Id v)+prj (Union v) = runId `fmap` gcast1 (Id v) {-# INLINE prjForce #-} -- | Extract the contents of a Union as a given type. -- If the Union isn't of that type, a runtime error occurs. prjForce :: (Typeable1 t, Member t r) => Union r v -> (t v -> a) -> a-prjForce u f = f <$> prj u <?> error "prjForce with an invalid type"+prjForce u f = f `fmap` prj u <?> error "prjForce with an invalid type" {-# INLINE decomp #-} -- | Try extracting the contents of a Union as a given type. -- If we can't, return a reduced Union that excludes the type we just checked. decomp :: Typeable1 t => Union (t :> r) v -> Either (Union r v) (t v)-decomp u = Right <$> prj u <?> Left (unsafeReUnion u)+decomp u = Right `fmap` prj u <?> Left (unsafeReUnion u) {-# INLINE weaken #-} weaken :: (Typeable1 t, Functor t) => Union r w -> Union (t :> r) w
+ src/Data/OpenUnion/Imports.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.OpenUnion.Imports( Applicative(..)+ , module Impl+ ) where++#if __GLASGOW_HASKELL__ < 710+import Control.Applicative(Applicative(..))+#endif+#if __GLASGOW_HASKELL__ >= 708+import Data.OpenUnion.Internal.OpenUnion2 as Impl+#else+import Data.OpenUnion.Internal.OpenUnion1 as Impl+#endif
src/Data/OpenUnion/Internal/Base.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE KindSignatures #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} #if MIN_VERSION_base(4,7,0) #define Typeable1 Typeable
src/Data/OpenUnion/Internal/OpenUnion1.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}+{-# LANGUAGE Safe #-} -- Only for MemberU below, when emulating Monad Transformers {-# LANGUAGE FunctionalDependencies, OverlappingInstances, UndecidableInstances #-}
src/Data/OpenUnion/Internal/OpenUnion2.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DataKinds, PolyKinds #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}+{-# LANGUAGE Safe #-} -- Only for MemberU below, when emulating Monad Transformers {-# LANGUAGE FunctionalDependencies, UndecidableInstances #-}@@ -24,17 +25,17 @@ -- -- The @`Member` t r@ specifies whether @t@ is present anywhere in the sum type -- @r@, where @t@ is some effectful type, e.g. @`Lift` `IO`@, @`State` Int`@.-class (Member' t r ~ True) => Member (t :: * -> *) r-instance (Member' t r ~ True) => Member t r+class (Member' t r ~ 'True) => Member (t :: * -> *) r+instance (Member' t r ~ 'True) => Member t r type family Member' (t :: * -> *) r :: Bool where- Member' t (t :> r) = True- Member' t () = False+ Member' t (t :> r) = 'True+ Member' t () = 'False Member' t (t' :> r) = Member' t r type family EQU (a :: k) (b :: k) :: Bool where- EQU a a = True- EQU a b = False+ EQU a a = 'True+ EQU a b = 'False -- | This class is used for emulating monad transformers class Member t r => MemberU (tag :: k -> * -> *) (t :: * -> *) r | tag r -> t@@ -42,6 +43,6 @@ class Member t r => MemberU' (f::Bool) (tag :: k -> * -> *) (t :: * -> *) r | tag r -> t-instance MemberU' True tag (tag e) (tag e :> r)-instance (Member' t (t' :> r) ~ True, MemberU tag t r) =>- MemberU' False tag t (t' :> r)+instance MemberU' 'True tag (tag e) (tag e :> r)+instance (Member' t (t' :> r) ~ 'True, MemberU tag t r) =>+ MemberU' 'False tag t (t' :> r)