elevator 0.1 → 0.1.1
raw patch · 2 files changed
+22/−8 lines, 2 files
Files
- elevator.cabal +1/−1
- src/Control/Elevator.hs +21/−7
elevator.cabal view
@@ -1,5 +1,5 @@ name: elevator -version: 0.1 +version: 0.1.1 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
src/Control/Elevator.hs view
@@ -1,4 +1,17 @@ {-# LANGUAGE CPP, TypeOperators, FlexibleContexts, DefaultSignatures, FlexibleInstances, ConstraintKinds, TypeFamilies, DataKinds #-} +----------------------------------------------------------------------------- +-- | +-- Module : Control.Elevator +-- Copyright : (c) Fumiaki Kinoshita 2014 +-- License : BSD3 +-- +-- Maintainer : Fumiaki Kinoshita <fumiexcel@gmail.com> +-- Stability : experimental +-- Portability : non-portable +-- +-- Automated effect elevator +-- +----------------------------------------------------------------------------- module Control.Elevator where import Control.Monad.Trans.State.Lazy as Lazy import Control.Monad.Trans.State.Strict as Strict @@ -39,7 +52,8 @@ elevate :: Elevate f g => f a -> g a elevate f = (id ||> toLoft) (liftU f) -{-# INLINE elevate #-} +{-# RULES "elevate/id" [~2] elevate = id #-} +{-# INLINE[2] elevate #-} instance Tower IO where type Floors IO = ST RealWorld :> Empty @@ -85,9 +99,9 @@ ||> lift . toLoft1 instance (Monoid w, Monad m, Tower m) => Tower (Lazy.WriterT w m) where - type Floors (Lazy.WriterT s m) = Lazy.Writer s - :> Strict.Writer s - :> Strict.WriterT s m + type Floors (Lazy.WriterT w m) = Lazy.Writer w + :> Strict.Writer w + :> Strict.WriterT w m :> Floors1 m toLoft = Lazy.writer . Lazy.runWriter ||> Lazy.writer . Strict.runWriter @@ -95,9 +109,9 @@ ||> lift . toLoft1 instance (Monoid w, Monad m, Tower m) => Tower (Strict.WriterT w m) where - type Floors (Strict.WriterT s m) = Lazy.Writer s - :> Strict.Writer s - :> Lazy.WriterT s m + type Floors (Strict.WriterT w m) = Lazy.Writer w + :> Strict.Writer w + :> Lazy.WriterT w m :> Floors1 m toLoft = Strict.writer . Lazy.runWriter ||> Strict.writer . Strict.runWriter