data-layer 1.0 → 1.0.2
raw patch · 5 files changed
+45/−67 lines, 5 filesdep +data-constructiondep ~lenssetup-changed
Dependencies added: data-construction
Dependency ranges changed: lens
Files
- Setup.hs +0/−2
- data-layer.cabal +33/−51
- src/Data/Layer.hs +3/−8
- src/Data/Layer/Coat.hs +7/−6
- src/Data/Layer/Immersed.hs +2/−0
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
data-layer.cabal view
@@ -1,53 +1,35 @@-name: data-layer-version: 1.0-synopsis: Data layering utilities. Layer is a data-type which wrapps other one, but keeping additional information. If you want to access content of simple newtype object, use Lens.Wrapper instead. --- description: -license: Apache-2.0-license-file: LICENSE-author: Wojciech Danilo-maintainer: Wojciech Danilo <wojciech.danilo@gmail.com>-stability: experimental-homepage: https://github.com/wdanilo/layer-bug-reports: https://github.com/wdanilo/layer/issues-copyright: Copyright (C) 2015 Wojciech Danilo-category: Text-build-type: Simple--- extra-source-files: -cabal-version: >=1.10---Library- hs-source-dirs: src- ghc-options: -Wall -O2- default-language: Haskell2010+name: data-layer+version: 1.0.2+cabal-version: >=1.10+build-type: Simple+license: Apache-2.0+license-file: LICENSE+copyright: Copyright (C) 2015 Wojciech Danilo+maintainer: Wojciech Danilo <wojciech.danilo@gmail.com>+stability: experimental+homepage: https://github.com/wdanilo/layer+bug-reports: https://github.com/wdanilo/layer/issues+synopsis: Data layering utilities. Layer is a data-type which wrapps other one, but keeping additional information. If you want to access content of simple newtype object, use Lens.Wrapper instead.+category: Text+author: Wojciech Danilo - default-extensions: ConstraintKinds- DataKinds- DefaultSignatures- DeriveDataTypeable- DeriveFoldable- DeriveFunctor- DeriveGeneric- DeriveTraversable- DoAndIfThenElse- EmptyDataDecls- FlexibleContexts- FlexibleInstances- GeneralizedNewtypeDeriving- InstanceSigs- LambdaCase- MultiParamTypeClasses- OverloadedStrings- StandaloneDeriving- TemplateHaskell- TupleSections- TypeOperators- ViewPatterns- TypeFamilies- - exposed-modules: Data.Layer- Data.Layer.Coat- Data.Layer.Immersed+library+ exposed-modules:+ Data.Layer+ Data.Layer.Coat+ Data.Layer.Immersed+ build-depends:+ base >=4.6 && <4.9,+ data-construction >=1.0,+ lens >=4.12.3+ default-language: Haskell2010+ default-extensions: ConstraintKinds DataKinds DefaultSignatures+ DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric+ DeriveTraversable DoAndIfThenElse EmptyDataDecls FlexibleContexts+ FlexibleInstances GeneralizedNewtypeDeriving InstanceSigs+ LambdaCase MultiParamTypeClasses OverloadedStrings+ StandaloneDeriving TemplateHaskell TupleSections TypeOperators+ ViewPatterns TypeFamilies+ hs-source-dirs: src+ ghc-options: -Wall -O2 - build-depends: base >=4.6 && <4.9- , lens
src/Data/Layer.hs view
@@ -17,7 +17,7 @@ default layered :: (Unlayered l ~ Unwrapped l, Wrapped l) => Lens' l (Unlayered l) layered = _Wrapped' -class Layered l => IsLayer l where+class IsLayer l where layer :: Unlayered l -> l unlayer :: Layered l => l -> Unlayered l@@ -35,10 +35,6 @@ default setLayeredM :: (Layered l, Monad m) => Unlayered l -> l -> m l setLayeredM = (fmap . fmap) return $ set layered -class LayeredM m l => IsLayerM m l where- layerM :: Unlayered l -> m l- default layerM :: (IsLayer l, Monad m) => Unlayered l -> m l- layerM = return . layer unlayerM :: LayeredM m l => l -> m (Unlayered l) unlayerM = viewLayeredM@@ -50,8 +46,7 @@ withLayeredM' = withLayeredM . (return .) --- === Layer generators === -class LayerGen m l where genLayer :: Unlayered l -> m l -+--class Cover m l where cover :: Unlayered l -> m l+--class Uncover m l where uncover :: l -> m (Unlayered l)
src/Data/Layer/Coat.hs view
@@ -5,6 +5,7 @@ import Prelude import Control.Lens import Control.Monad+import Data.Construction import Data.Layer @@ -58,13 +59,13 @@ -- === Coat generator === -class CoatGen m a where genCoat :: Uncoated a -> m a+class CoatConstructor m a where constructCoat :: Uncoated a -> m a instance {-# OVERLAPPABLE #-} ( Monad m- , Uncoated (Unlayered a) ~ Uncoated a- , CoatGen m (Unlayered a)- , LayerGen m a- ) => CoatGen m a where genCoat = genCoat >=> genLayer-instance {-# OVERLAPPABLE #-} Monad m => CoatGen m (Coat a) where genCoat = return . Coat+ , CoatConstructor m (Destructed a)+ , Uncoated a ~ Uncoated (Destructed a)+ , Constructor m a+ ) => CoatConstructor m a where constructCoat = constructCoat >=> construct+instance {-# OVERLAPPABLE #-} Monad m => CoatConstructor m (Coat a) where constructCoat = return . Coat --class Destruction m a where destroy :: a -> m (Uncoated a)
src/Data/Layer/Immersed.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE UndecidableInstances #-}+ module Data.Layer.Immersed where