Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This code is taken from https://stackoverflow.com/questions/28003135/is-it-possible-to-encode-a-generic-lift-function-in-haskell
to allow a generic lift operation over an Applicative
context
So if you have a function: Int -> Text -> IO Int
, it can be lifted to have all of its parameters
in IO
:
f :: Int -> Text -> IO Int lifted :: IO Int -> IO Text -> IO Int lifted = to @IO f
Synopsis
- class Applicative f => ApplyVariadic f a b where
- allTo :: forall f a b. ApplyVariadic f a b => a -> b
- class Monad f => ApplyVariadic1 f a b where
- argsTo :: forall f a b. ApplyVariadic1 f a b => a -> b
- class Applicative f => ApplyVariadic2 f g a b where
- outTo :: forall g f a b. ApplyVariadic2 f g a b => (forall x. f x -> g x) -> a -> b
Documentation
class Applicative f => ApplyVariadic f a b where Source #
Typeclass for lifting pure functions to effectful arguments and results
applyVariadic :: f a -> b Source #
Instances
(Applicative f, b ~ f a) => ApplyVariadic f a b Source # | |
Defined in Data.Registry.Lift applyVariadic :: f a -> b Source # | |
(Applicative f, ApplyVariadic f a' b', b ~ (f a -> b')) => ApplyVariadic f (a -> a') b Source # | |
Defined in Data.Registry.Lift applyVariadic :: f (a -> a') -> b Source # |
allTo :: forall f a b. ApplyVariadic f a b => a -> b Source #
Lift a pure function to effectful arguments and results
class Monad f => ApplyVariadic1 f a b where Source #
Typeclass for lifting impure functions to effectful arguments and results
applyVariadic1 :: f a -> b Source #
Instances
(Monad f, b ~ f a) => ApplyVariadic1 f (f a) b Source # | |
Defined in Data.Registry.Lift applyVariadic1 :: f (f a) -> b Source # | |
(Monad f, ApplyVariadic1 f a' b', b ~ (f a -> b')) => ApplyVariadic1 f (a -> a') b Source # | |
Defined in Data.Registry.Lift applyVariadic1 :: f (a -> a') -> b Source # |
argsTo :: forall f a b. ApplyVariadic1 f a b => a -> b Source #
Lift an effectful function to effectful arguments and results
class Applicative f => ApplyVariadic2 f g a b where Source #
Typeclass for lifting a function with a result of type m b into a function with a result of type n b
applyVariadic2 :: (forall x. f x -> g x) -> a -> b Source #
Instances
(Applicative f, b ~ g a) => ApplyVariadic2 f g (f a) b Source # | |
Defined in Data.Registry.Lift applyVariadic2 :: (forall x. f x -> g x) -> f a -> b Source # | |
(Applicative f, ApplyVariadic2 f g a' b', b ~ (a -> b')) => ApplyVariadic2 f g (a -> a') b Source # | |
Defined in Data.Registry.Lift applyVariadic2 :: (forall x. f x -> g x) -> (a -> a') -> b Source # |
outTo :: forall g f a b. ApplyVariadic2 f g a b => (forall x. f x -> g x) -> a -> b Source #
Lift a function returning an effectful result to a function returning another effectful result