| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Bluefin.Internal.CloneableHandle
Synopsis
- app :: forall h2 h1 (e :: Effects). Handle h2 => (h1 :~> h2) e -> h1 e -> h2 e
- class Handle h => CloneableHandle (h :: Effects -> Type) where
- withEffToIOCloneHandle :: forall (e1 :: Effects) (es :: Effects) h a. (e1 :> es, CloneableHandle h) => IOE e1 -> h es -> ((forall r. (forall (e :: Effects). IOE e -> h e -> Eff e r) -> IO r) -> IO a) -> Eff es a
- cloneHandleClass :: forall (e1 :: Effects) (es :: Effects) h r. (e1 :> es, CloneableHandle h) => h e1 -> (forall (e :: Effects). h e -> Eff (e :& es) r) -> Eff es r
- newtype HandleCloner (h1 :: Effects -> Type) (h2 :: Effects -> Type) (es :: Effects) = MkHandleCloner (forall r. h1 es -> (forall (e :: Effects). h2 e -> Eff (e :& es) r) -> Eff es r)
- cloneHandle2 :: forall h1 h2 (e1 :: Effects) (es :: Effects) r. (Handle h1, Handle h2, e1 :> es) => HandleCloner h1 h2 es -> h1 e1 -> (forall (e :: Effects). h2 e -> Eff (e :& es) r) -> Eff es r
- newtype CloneableHandleD (h :: Effects -> Type) = MkCloneableHandleD (forall (e :: Effects). HandleCloner h h e)
- hcIOE :: forall (e :: Effects). HandleCloner IOE IOE e
- hcState :: forall s (e :: Effects). HandleCloner (State s) (State s) e
- hcException :: forall ex (e :: Effects). HandleCloner (Exception ex) (Exception ex) e
- hcReader :: forall r (e :: Effects). HandleCloner (Reader r) (Reader r) e
- hcHandleReader :: forall (h :: Effects -> Type) (e :: Effects). CloneableHandle h => HandleCloner (HandleReader h) (HandleReader h) e
- newtype ((h1 :: Effects -> Type) :~> (h2 :: Effects -> Type)) (es :: Effects) = MkArrow (forall (e :: Effects). h1 e -> h2 (e :& es))
- abstract :: forall h2 h1 (es :: Effects). Handle h2 => (forall (e :: Effects). h1 e -> h2 (e :& es)) -> (h1 :~> h2) es
- lmapHC :: forall (h :: Effects -> Type) (h2 :: Effects -> Type) (h1 :: Effects -> Type) (e :: Effects). (Handle h, Handle h2) => (h1 :~> h2) e -> HandleCloner h2 h e -> HandleCloner h1 h e
- pureHC :: forall h2 (e :: Effects) (h1 :: Effects -> Type). h2 e -> HandleCloner h1 h2 e
- fmapHC :: forall (h :: Effects -> Type) (h1 :: Effects -> Type) (h2 :: Effects -> Type) (e :: Effects). (Handle h, Handle h1, Handle h2) => (h1 :~> h2) e -> HandleCloner h h1 e -> HandleCloner h h2 e
- apHC :: forall (h :: Effects -> Type) (h1 :: Effects -> Type) (h2 :: Effects -> Type) (e :: Effects). (Handle h, Handle h1, Handle h2) => HandleCloner h (h1 :~> h2) e -> HandleCloner h h1 e -> HandleCloner h h2 e
- liftHC2 :: forall (h :: Effects -> Type) h1 h2 hr (es :: Effects). (Handle h, Handle h1, Handle h2) => (forall (e :: Effects). h1 e -> h2 e -> hr e) -> HandleCloner h h1 es -> HandleCloner h h2 es -> HandleCloner h hr es
- newtype GenericCloneableHandle (h :: k -> Type) (e :: k) = MkGenericCloneableHandle (h e)
- class Handle h => GCloneableHandle (h :: Effects -> Type) where
- gCloneableHandle :: forall (h :: Effects -> Type). (Handle h, Generic1 h, GCloneableHandle (Rep1 h)) => CloneableHandleD h
- getHandleCloner :: forall (h :: Effects -> Type) (e :: Effects). GCloneableHandle h => HandleCloner h h e
- class MonadIO m => MonadUnliftIO (m :: Type -> Type) where
- withRunInIO :: ((forall a. m a -> IO a) -> IO b) -> m b
- class Monad m => MonadIO (m :: Type -> Type) where
- class Generic1 (f :: k -> Type)
Documentation
class Handle h => CloneableHandle (h :: Effects -> Type) where Source #
You can define a CloneableHandle instance for your Handle as
long as it is a product type of CloneableHandles. To define the
instance, use DerivingVia and GenericCloneableHandle. For
example:
data MyHandle e = MkMyHandle (ExceptionString e) (StateInt e) deriving (Generic,Generic1) deriving (Handle) viaOneWayCoercibleHandleMyHandle deriving (CloneableHandle) viaGenericCloneableHandleMyHandle instance (e:>es) =>OneWayCoercible(MyHandle e) (MyHandle es) whereoneWayCoercibleImpl=gOneWayCoercible
Instances
cloneHandleClass :: forall (e1 :: Effects) (es :: Effects) h r. (e1 :> es, CloneableHandle h) => h e1 -> (forall (e :: Effects). h e -> Eff (e :& es) r) -> Eff es r Source #
newtype HandleCloner (h1 :: Effects -> Type) (h2 :: Effects -> Type) (es :: Effects) Source #
Constructors
| MkHandleCloner (forall r. h1 es -> (forall (e :: Effects). h2 e -> Eff (e :& es) r) -> Eff es r) |
Instances
| (Handle h1, Handle h2) => OneWayCoercible (HandleCloner h1 h2 e :: Type) (HandleCloner h1 h2 es :: Type) Source # | |
Defined in Bluefin.Internal.CloneableHandle Methods oneWayCoercibleImpl :: OneWayCoercibleD (HandleCloner h1 h2 e) (HandleCloner h1 h2 es) Source # | |
| (Handle h1, Handle h2) => Handle (HandleCloner h1 h2) Source # | |
Defined in Bluefin.Internal.CloneableHandle Methods handleImpl :: HandleD (HandleCloner h1 h2) Source # mapHandle :: forall (e :: Effects) (es :: Effects). e :> es => HandleCloner h1 h2 e -> HandleCloner h1 h2 es Source # | |
cloneHandle2 :: forall h1 h2 (e1 :: Effects) (es :: Effects) r. (Handle h1, Handle h2, e1 :> es) => HandleCloner h1 h2 es -> h1 e1 -> (forall (e :: Effects). h2 e -> Eff (e :& es) r) -> Eff es r Source #
newtype CloneableHandleD (h :: Effects -> Type) Source #
Constructors
| MkCloneableHandleD (forall (e :: Effects). HandleCloner h h e) |
hcException :: forall ex (e :: Effects). HandleCloner (Exception ex) (Exception ex) e Source #
hcHandleReader :: forall (h :: Effects -> Type) (e :: Effects). CloneableHandle h => HandleCloner (HandleReader h) (HandleReader h) e Source #
newtype ((h1 :: Effects -> Type) :~> (h2 :: Effects -> Type)) (es :: Effects) infixr 9 Source #
abstract :: forall h2 h1 (es :: Effects). Handle h2 => (forall (e :: Effects). h1 e -> h2 (e :& es)) -> (h1 :~> h2) es Source #
lmapHC :: forall (h :: Effects -> Type) (h2 :: Effects -> Type) (h1 :: Effects -> Type) (e :: Effects). (Handle h, Handle h2) => (h1 :~> h2) e -> HandleCloner h2 h e -> HandleCloner h1 h e Source #
fmapHC :: forall (h :: Effects -> Type) (h1 :: Effects -> Type) (h2 :: Effects -> Type) (e :: Effects). (Handle h, Handle h1, Handle h2) => (h1 :~> h2) e -> HandleCloner h h1 e -> HandleCloner h h2 e Source #
apHC :: forall (h :: Effects -> Type) (h1 :: Effects -> Type) (h2 :: Effects -> Type) (e :: Effects). (Handle h, Handle h1, Handle h2) => HandleCloner h (h1 :~> h2) e -> HandleCloner h h1 e -> HandleCloner h h2 e infixl 9 Source #
liftHC2 :: forall (h :: Effects -> Type) h1 h2 hr (es :: Effects). (Handle h, Handle h1, Handle h2) => (forall (e :: Effects). h1 e -> h2 e -> hr e) -> HandleCloner h h1 es -> HandleCloner h h2 es -> HandleCloner h hr es Source #
newtype GenericCloneableHandle (h :: k -> Type) (e :: k) Source #
You can use DerivingVia with GenericCloneableHandle to derive
a CloneableHandle instance for your type, as long as it is a
product type of CloneableHandles.
Constructors
| MkGenericCloneableHandle (h e) |
Instances
| Handle h => Handle (GenericCloneableHandle h) Source # | |
Defined in Bluefin.Internal.CloneableHandle Methods handleImpl :: HandleD (GenericCloneableHandle h) Source # mapHandle :: forall (e :: Effects) (es :: Effects). e :> es => GenericCloneableHandle h e -> GenericCloneableHandle h es Source # | |
| (Handle h, Generic1 h, GCloneableHandle (Rep1 h)) => CloneableHandle (GenericCloneableHandle h) Source # | |
Defined in Bluefin.Internal.CloneableHandle Methods cloneableHandleImpl :: CloneableHandleD (GenericCloneableHandle h) Source # | |
class Handle h => GCloneableHandle (h :: Effects -> Type) where Source #
Generic implementation detail of
GenericCloneableHandle. Bluefin users should never need to use
this directly.
Methods
Instances
| CloneableHandle h => GCloneableHandle (Rec1 h) Source # | A cloneable handle is generically cloneable |
Defined in Bluefin.Internal.CloneableHandle Methods | |
| (GCloneableHandle h1, GCloneableHandle h2) => GCloneableHandle (h1 :*: h2) Source # | A pair of cloneable handles is generically cloneable |
Defined in Bluefin.Internal.CloneableHandle Methods gCloneableHandleImpl :: CloneableHandleD (h1 :*: h2) Source # | |
| GCloneableHandle h => GCloneableHandle (M1 i t h) Source # | An annotated cloneable handle is generically cloneable |
Defined in Bluefin.Internal.CloneableHandle Methods gCloneableHandleImpl :: CloneableHandleD (M1 i t h) Source # | |
gCloneableHandle :: forall (h :: Effects -> Type). (Handle h, Generic1 h, GCloneableHandle (Rep1 h)) => CloneableHandleD h Source #
getHandleCloner :: forall (h :: Effects -> Type) (e :: Effects). GCloneableHandle h => HandleCloner h h e Source #
class MonadIO m => MonadUnliftIO (m :: Type -> Type) where #
Monads which allow their actions to be run in IO.
While MonadIO allows an IO action to be lifted into another
monad, this class captures the opposite concept: allowing you to
capture the monadic context. Note that, in order to meet the laws
given below, the intuition is that a monad must have no monadic
state, but may have monadic context. This essentially limits
MonadUnliftIO to ReaderT and IdentityT transformers on top of
IO.
Laws. For any function run provided by withRunInIO, it must meet the
monad transformer laws as reformulated for MonadUnliftIO:
run . return = return
run (m >>= f) = run m >>= run . f
Instances of MonadUnliftIO must also satisfy the following laws:
- Identity law
withRunInIO (\run -> run m) = m- Inverse law
withRunInIO (\_ -> m) = liftIO m
As an example of an invalid instance, a naive implementation of
MonadUnliftIO (StateT s m) might be
withRunInIO inner =
StateT $ \s ->
withRunInIO $ \run ->
inner (run . flip evalStateT s)
This breaks the identity law because the inner run m would throw away
any state changes in m.
Since: unliftio-core-0.1.0.0
Methods
withRunInIO :: ((forall a. m a -> IO a) -> IO b) -> m b #
Convenience function for capturing the monadic context and running an IO
action with a runner function. The runner function is used to run a monadic
action m in IO.
Since: unliftio-core-0.1.0.0
Instances
| MonadUnliftIO IO | |
Defined in Control.Monad.IO.Unlift | |
| e :> es => MonadUnliftIO (EffReader (IOE e) es) Source # | You probably want to use |
Defined in Bluefin.Internal | |
| MonadUnliftIO m => MonadUnliftIO (IdentityT m) | |
Defined in Control.Monad.IO.Unlift | |
| MonadUnliftIO m => MonadUnliftIO (ReaderT r m) | |
Defined in Control.Monad.IO.Unlift | |
class Monad m => MonadIO (m :: Type -> Type) where #
Monads in which IO computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Methods
Lift a computation from the IO monad.
This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations
(i.e. IO is the base monad for the stack).
Example
import Control.Monad.Trans.State -- from the "transformers" library printState :: Show s => StateT s IO () printState = do state <- get liftIO $ print state
Had we omitted , we would have ended up with this error:liftIO
• Couldn't match type ‘IO’ with ‘StateT s IO’ Expected type: StateT s IO () Actual type: IO ()
The important part here is the mismatch between StateT s IO () and .IO ()
Luckily, we know of a function that takes an and returns an IO a(m a): ,
enabling us to run the program and see the expected results:liftIO
> evalStateT printState "hello" "hello" > evalStateT printState 3 3
Instances
class Generic1 (f :: k -> Type) #
Representable types of kind * -> * (or kind k -> *, when PolyKinds
is enabled).
This class is derivable in GHC with the DeriveGeneric flag on.
A Generic1 instance must satisfy the following laws:
from1.to1≡idto1.from1≡id