vinyl-utils 0.3.0.0 → 0.3.0.1
raw patch · 8 files changed
+171/−171 lines, 8 filesdep ~vinylsetup-changed
Dependency ranges changed: vinyl
Files
- LICENSE +30/−30
- README.md +2/−2
- Setup.hs +2/−2
- changelog.md +24/−24
- src/Data/Vinyl/Utils/Compose.hs +25/−25
- src/Data/Vinyl/Utils/Field.hs +44/−44
- src/Data/Vinyl/Utils/Proxy.hs +42/−42
- vinyl-utils.cabal +2/−2
LICENSE view
@@ -1,30 +1,30 @@-Copyright (c) 2014, Marcin Mrotek - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Marcin Mrotek nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2014, Marcin Mrotek++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Marcin Mrotek nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md view
@@ -1,2 +1,2 @@-# vinyl-utils -Utilities for Vinyl +# vinyl-utils+Utilities for Vinyl
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple -main = defaultMain +import Distribution.Simple+main = defaultMain
changelog.md view
@@ -1,24 +1,24 @@-0.2.0.1 -------- - -* Record type class is now polykinded. - -0.2.0.0 -------- - -* Updated for base-4.8 -* Added operations on field constraints. -* Added proxy record generation. -* Removed ConstApplicative type class, replaced by generation from proxy record. - -0.1.0.0 -------- - -* Updated for Vinyl 0.5.* -* Removed slicing lens and overwriting (already in Vinyl proper). - -0.0.0.0 ------- - -* Initial commit. - +0.2.0.1+-------++* Record type class is now polykinded.++0.2.0.0+-------++* Updated for base-4.8+* Added operations on field constraints.+* Added proxy record generation.+* Removed ConstApplicative type class, replaced by generation from proxy record.++0.1.0.0+-------++* Updated for Vinyl 0.5.*+* Removed slicing lens and overwriting (already in Vinyl proper).++0.0.0.0+------++* Initial commit.+
src/Data/Vinyl/Utils/Compose.hs view
@@ -1,25 +1,25 @@-{-| -Module : Data.Vinyl.Utils.Compose -Copyright : (c) Marcin Mrotek, 2014 -License : BSD3 -Maintainer : marcin.jan.mrotek@gmail.com - -Operations on composed functor records. --} - -{-# LANGUAGE - DataKinds - , PolyKinds - #-} - -{-# OPTIONS_HADDOCK show-extensions #-} - -module Data.Vinyl.Utils.Compose - ( rtraverse1 ) where - -import Data.Vinyl.Functor -import Data.Vinyl - -rtraverse1 :: Applicative f => Rec (Compose f g) rs -> f (Rec g rs) --- ^Traverse a record parametrized with a composition of functors, leaving the inner functor. -rtraverse1 = rtraverse getCompose +{-|+Module : Data.Vinyl.Utils.Compose+Copyright : (c) Marcin Mrotek, 2014+License : BSD3+Maintainer : marcin.jan.mrotek@gmail.com++Operations on composed functor records.+-}++{-# LANGUAGE+ DataKinds+ , PolyKinds+ #-}++{-# OPTIONS_HADDOCK show-extensions #-}++module Data.Vinyl.Utils.Compose + ( rtraverse1 ) where++import Data.Vinyl.Functor+import Data.Vinyl++rtraverse1 :: Applicative f => Rec (Compose f g) rs -> f (Rec g rs)+-- ^Traverse a record parametrized with a composition of functors, leaving the inner functor.+rtraverse1 = rtraverse getCompose
src/Data/Vinyl/Utils/Field.hs view
@@ -1,44 +1,44 @@-{-| -Module : Data.Vinyl.Utils.Field -Copyright : (c) Marcin Mrotek, 2014 -License : BSD3 -Maintainer : marcin.jan.mrotek@gmail.com - -Manipulation of constraints that apply to field labels (as opposed to actual types stored in the record). --} - -{-# LANGUAGE - ConstraintKinds - , DataKinds - , GADTs - , PolyKinds - , TypeFamilies - , TypeOperators - #-} - -{-# OPTIONS_HADDOCK show-extensions #-} - -module Data.Vinyl.Utils.Field where - -import Data.Proxy -import Data.Vinyl -import GHC.Exts - --- |Assert that all field labels in a given type list satisfy a given constraint. -type family FieldAll (rs :: [k]) (c :: k -> Constraint) :: Constraint where - FieldAll '[] c = () - FieldAll (r ': rs) c = (c r, FieldAll rs c) - --- |A data type that reifies a constraint. Pattern match on the 'DictProxy' constructor to bring the constraint into scope. -data DictProxy c a where - DictProxy :: c a => DictProxy c a - -getProxy :: DictProxy c a -> Proxy a --- ^Obtain a 'Proxy' from a 'DictProxy', forgetting its constraint. -getProxy DictProxy = Proxy - -reifyFieldConstraint :: FieldAll rs c => proxy c -> Rec Proxy rs -> Rec (DictProxy c) rs --- ^Given a dummy record and a constraint that applies to all field labels, reify the constraint for each field label. -reifyFieldConstraint _ RNil = RNil -reifyFieldConstraint c (Proxy :& ps) = DictProxy :& reifyFieldConstraint c ps - +{-|+Module : Data.Vinyl.Utils.Field+Copyright : (c) Marcin Mrotek, 2014+License : BSD3+Maintainer : marcin.jan.mrotek@gmail.com++Manipulation of constraints that apply to field labels (as opposed to actual types stored in the record).+-}++{-# LANGUAGE + ConstraintKinds+ , DataKinds+ , GADTs+ , PolyKinds+ , TypeFamilies+ , TypeOperators+ #-}++{-# OPTIONS_HADDOCK show-extensions #-}++module Data.Vinyl.Utils.Field where++import Data.Proxy+import Data.Vinyl+import GHC.Exts++-- |Assert that all field labels in a given type list satisfy a given constraint.+type family FieldAll (rs :: [k]) (c :: k -> Constraint) :: Constraint where+ FieldAll '[] c = ()+ FieldAll (r ': rs) c = (c r, FieldAll rs c)++-- |A data type that reifies a constraint. Pattern match on the 'DictProxy' constructor to bring the constraint into scope.+data DictProxy c a where+ DictProxy :: c a => DictProxy c a++getProxy :: DictProxy c a -> Proxy a+-- ^Obtain a 'Proxy' from a 'DictProxy', forgetting its constraint.+getProxy DictProxy = Proxy++reifyFieldConstraint :: FieldAll rs c => proxy c -> Rec Proxy rs -> Rec (DictProxy c) rs+-- ^Given a dummy record and a constraint that applies to all field labels, reify the constraint for each field label.+reifyFieldConstraint _ RNil = RNil+reifyFieldConstraint c (Proxy :& ps) = DictProxy :& reifyFieldConstraint c ps+
src/Data/Vinyl/Utils/Proxy.hs view
@@ -1,42 +1,42 @@-{-| -Module : Data.Vinyl.Utils.Proxy -Copyright : (c) Marcin Mrotek, 2014 -License : BSD3 -Maintainer : marcin.jan.mrotek@gmail.com - -Create a dummy record parametrized by 'Proxy', for the purpose of guiding code generation through pattern matching. --} - -{-# LANGUAGE - DataKinds - , GADTs - , PolyKinds - , RankNTypes - , TypeOperators - #-} - -module Data.Vinyl.Utils.Proxy - ( module Data.Vinyl.Utils.Proxy - , Proxy (..) - ) where - -import Data.Proxy -import Data.Vinyl - --- |Create a dummy record parametrized by 'Proxy'. The class is named 'Record' to signify that every possible type list is its instance. -class Record (rs :: [k]) where - proxyRecord :: Rec Proxy rs - -instance Record '[] where - proxyRecord = RNil - -instance Record rs => Record (r ': rs) where - proxyRecord = Proxy :& proxyRecord - -recPure :: forall (f :: k -> *) (rs :: [k]). Record rs => (forall (a :: k). f a) -> Rec f rs -recPure = recPure' proxyRecord - -recPure' :: forall (f :: k -> *) (rs :: [k]). Rec Proxy rs -> (forall (a :: k). f a) -> Rec f rs -recPure' RNil _ = RNil -recPure' (Proxy :& ps) a = a :& recPure' ps a - +{-|+Module : Data.Vinyl.Utils.Proxy+Copyright : (c) Marcin Mrotek, 2014+License : BSD3+Maintainer : marcin.jan.mrotek@gmail.com++Create a dummy record parametrized by 'Proxy', for the purpose of guiding code generation through pattern matching.+-}++{-# LANGUAGE+ DataKinds+ , GADTs+ , PolyKinds+ , RankNTypes+ , TypeOperators+ #-}++module Data.Vinyl.Utils.Proxy + ( module Data.Vinyl.Utils.Proxy+ , Proxy (..)+ ) where++import Data.Proxy+import Data.Vinyl++-- |Create a dummy record parametrized by 'Proxy'. The class is named 'Record' to signify that every possible type list is its instance.+class Record (rs :: [k]) where+ proxyRecord :: Rec Proxy rs++instance Record '[] where+ proxyRecord = RNil++instance Record rs => Record (r ': rs) where+ proxyRecord = Proxy :& proxyRecord++recPure :: forall (f :: k -> *) (rs :: [k]). Record rs => (forall (a :: k). f a) -> Rec f rs+recPure = recPure' proxyRecord++recPure' :: forall (f :: k -> *) (rs :: [k]). Rec Proxy rs -> (forall (a :: k). f a) -> Rec f rs+recPure' RNil _ = RNil+recPure' (Proxy :& ps) a = a :& recPure' ps a+
vinyl-utils.cabal view
@@ -1,5 +1,5 @@ name: vinyl-utils -version: 0.3.0.0 +version: 0.3.0.1 synopsis: Utilities for vinyl description: Operations on records parametrized with various kinds of functors. license: BSD3 @@ -31,7 +31,7 @@ build-depends: base >= 4.8 && < 6 ,contravariant >= 1.3 && < 1.5 ,transformers >= 0.4 && < 0.6 - ,vinyl >= 0.5 && < 0.6 + ,vinyl >= 0.5 && < 0.8 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall