elevator 0.2.2 → 0.2.3
raw patch · 3 files changed
+21/−22 lines, 3 filesdep ~extensiblePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: extensible
API changes (from Hackage documentation)
- Control.Elevator: instance Forall Functor xs => Tower (League xs)
+ Control.Elevator: Union :: (:|) (k -> *) (K1 k a) xs -> Union
+ Control.Elevator: getUnion :: Union -> (:|) (k -> *) (K1 k a) xs
+ Control.Elevator: newtype Union (xs :: [k -> *]) (a :: k) :: [k -> *] -> k -> *
+ Control.Elevator: reunion :: (:*) (k -> *) (Gondola k m) xs -> Union k xs a -> m a
- Control.Elevator: Gondola :: (forall a. g a -> f a) -> Gondola f g
+ Control.Elevator: Gondola :: (forall (a :: k). g a -> f a) -> Gondola
- Control.Elevator: newtype Gondola f g
+ Control.Elevator: newtype Gondola (f :: k -> *) (g :: k -> *) :: (k -> *) -> (k -> *) -> *
- Control.Elevator: runGondola :: Gondola f g -> forall a. g a -> f a
+ Control.Elevator: runGondola :: Gondola -> forall (a :: k). g a -> f a
- Control.Elevator: rung :: (forall x. f x -> g x) -> Gondola g :* fs -> Gondola g :* (f : fs)
+ Control.Elevator: rung :: (forall (x :: k). f x -> g x) -> (:*) (k -> *) (Gondola k g) fs -> (:*) (k -> *) (Gondola k g) ((:) (k -> *) f fs)
Files
- CHANGELOG.md +8/−0
- elevator.cabal +2/−2
- src/Control/Elevator.hs +11/−20
CHANGELOG.md view
@@ -1,3 +1,11 @@+0.2.3 +--------------------------------- +* No longer supports `League` + +0.2.2 +--------------------------------- +* Supported newer version of `extensible` + 0.2.1 --------------------------------- * Re-exported some `extensible` combinators.
elevator.cabal view
@@ -1,5 +1,5 @@ name: elevator -version: 0.2.2 +version: 0.2.3 synopsis: Immediately lifts to a desired level description: This package provides 'elevate' function which composes 'lift'-like transformations automatically. homepage: https://github.com/fumieval/elevator @@ -24,6 +24,6 @@ library exposed-modules: Control.Elevator other-extensions: TypeOperators, FlexibleContexts, FlexibleInstances, ConstraintKinds, TypeFamilies, DataKinds - build-depends: base >= 4.7 && <5, transformers >= 0.3 && <0.5, extensible >= 0.3 && <0.4 + build-depends: base >= 4.7 && <5, transformers >= 0.3 && <0.5, extensible >= 0.3.2 && <0.4 hs-source-dirs: src default-language: Haskell2010
src/Control/Elevator.hs view
@@ -23,7 +23,11 @@ , (:*)(Nil) , (*++*) , mapGondolas- , liftGondolas) where+ , liftGondolas+ -- * Open unions+ , Union(..)+ , reunion+ ) where import Control.Monad.Trans.State.Lazy as Lazy import Control.Monad.Trans.State.Strict as Strict import Control.Monad.Trans.Writer.Lazy as Lazy@@ -33,10 +37,9 @@ import Control.Monad.Trans.Identity import Data.Functor.Identity import Data.Extensible+import Data.Extensible.Union import Data.Extensible.Internal import Data.Extensible.Internal.Rig (views)-import Data.Extensible.Union-import Data.Extensible.League import Control.Applicative import Control.Monad import Control.Monad.Trans.Class@@ -63,23 +66,12 @@ -- | Lift a thing, automatically. elevate :: Elevate f g => f a -> g a-elevate = views sector runGondola stairs1+elevate = runGondolas stairs1 {-# RULES "elevate/id" [~2] elevate = id #-} {-# INLINE[2] elevate #-} ---------------------------------------------------------------------------- --- | Transformation between effects-newtype Gondola f g = Gondola { runGondola :: forall a. g a -> f a }---- | Add a new transformation.-rung :: (forall x. f x -> g x) -> Gondola g :* fs -> Gondola g :* (f ': fs)-rung f = (<:) (Gondola f)-infixr 0 `rung`--mapGondolas :: (forall x. m x -> n x) -> Gondola m :* xs -> Gondola n :* xs-mapGondolas g = hmap (\(Gondola f) -> Gondola $ g . f)- -- | A class of types which have bases. class Tower f where type Floors (f :: * -> *) :: [* -> *]@@ -100,6 +92,9 @@ liftGondolas :: (Monad m, Tower m, MonadTrans t) => Gondola (t m) :* Floors1 m liftGondolas = mapGondolas lift stairs1 +mapGondolas :: (forall x. m x -> n x) -> Gondola m :* xs -> Gondola n :* xs+mapGondolas g = hmap (\(Gondola f) -> Gondola $ g . f)+ instance Tower IO where type Floors IO = '[ST RealWorld, Identity] stairs = stToIO `rung` return . runIdentity `rung` Nil@@ -116,11 +111,7 @@ instance Generate xs => Tower (Union xs) where type Floors (Union xs) = xs- stairs = htabulate $ \pos -> Gondola $ Union . UnionAt pos . Flux id--instance Forall Functor xs => Tower (League xs) where- type Floors (League xs) = xs- stairs = htabulateFor (Proxy :: Proxy Functor) $ \pos -> Gondola $ \f -> League $ UnionAt pos $ Fuse (<$>f)+ stairs = htabulate $ \pos -> Gondola $ Union . UnionAt pos . K1 instance (Monad m, Tower m) => Tower (Lazy.StateT s m) where type Floors (Lazy.StateT s m) = Floors1 m