elevator 0.1.2 → 0.1.3
raw patch · 5 files changed
+84/−10 lines, 5 files
Files
- .gitignore +58/−0
- .travis.yml +1/−0
- CHANGELOG.md +11/−0
- elevator.cabal +5/−2
- src/Control/Elevator.hs +9/−8
+ .gitignore view
@@ -0,0 +1,58 @@+dist +cabal-dev +*.o +*.hi +*.chi +*.chs.h +.virtualenv +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +cabal.config + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store+.AppleDouble+.LSOverride++# Icon must end with two \r+Icon ++# Thumbnails+._*++# Files that might appear on external disk+.Spotlight-V100+.Trashes++# Directories potentially created on remote AFP share+.AppleDB+.AppleDesktop+Network Trash Folder+Temporary Items+.apdisk+ +# Windows +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp
+ .travis.yml view
@@ -0,0 +1,1 @@+language: haskell
+ CHANGELOG.md view
@@ -0,0 +1,11 @@+0.1.3 +--------------------------------- +* Prevent the reckress type checking of GHC so that it works on older GHC and shows sane signature. + +0.1.2 +--------------------------------- +* Added `Identity` monad to the default definition of `Floors`. + +0.1.1 +--------------------------------- +* Added `elevate = id` pragma for efficiency.
elevator.cabal view
@@ -1,5 +1,5 @@ name: elevator -version: 0.1.2 +version: 0.1.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 @@ -10,7 +10,10 @@ copyright: Copyright (C) 2014 Fumiaki Kinoshita category: Data build-type: Simple --- extra-source-files: +extra-source-files: + CHANGELOG.md + .travis.yml + .gitignore cabal-version: >=1.10 source-repository head
src/Control/Elevator.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, TypeOperators, FlexibleContexts, DefaultSignatures, FlexibleInstances, ConstraintKinds, TypeFamilies, DataKinds #-} +{-# LANGUAGE CPP, TypeOperators, FlexibleContexts, Rank2Types, DefaultSignatures, FlexibleInstances, ConstraintKinds, TypeFamilies, DataKinds, UndecidableInstances #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Elevator @@ -41,21 +41,22 @@ #endif class Tower f where - type Floors f :: List (* -> *) + type Floors (f :: * -> *) :: List (* -> *) type Floors f = Identity :> Empty + type Floors1 f :: List (* -> *) + type Floors1 f = f :> Floors f toLoft :: Union (Floors f) a -> f a default toLoft :: Applicative f => Union (Identity :> Empty) a -> f a toLoft = pure . runIdentity ||> exhaust -type Elevate f g = (Tower g, f ∈ Floors1 g) - -type Floors1 g = g :> Floors g + toLoft1 :: Union (Floors1 f) a -> f a + default toLoft1 :: Union (f :> Floors f) a -> f a + toLoft1 = id ||> toLoft -toLoft1 :: Tower f => Union (Floors1 f) a -> f a -toLoft1 = id ||> toLoft +type Elevate f g = (Tower g, f ∈ Floors1 g) elevate :: Elevate f g => f a -> g a -elevate f = (id ||> toLoft) (liftU f) +elevate f = toLoft1 (liftU f) {-# RULES "elevate/id" [~2] elevate = id #-} {-# INLINE[2] elevate #-}