vinyl 0.5.2 → 0.5.3
raw patch · 5 files changed
+28/−3 lines, 5 files
Files
- CHANGELOG.md +4/−0
- Data/Vinyl/Core.hs +18/−0
- Data/Vinyl/Functor.hs +3/−0
- tests/Intro.lhs +2/−2
- vinyl.cabal +1/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.5.3++Added a concise `Show` instance for `Const`.+ # 0.5.2 Ported the tutorial to haddocks (andrewthad)
Data/Vinyl/Core.hs view
@@ -25,6 +25,8 @@ import Data.Typeable (Proxy(..)) import Data.List (intercalate) import Data.Vinyl.TypeLevel+import Data.Type.Equality (TestEquality (..), (:~:) (..))+import Data.Type.Coercion (TestCoercion (..), Coercion (..)) -- | A record is parameterized by a universe @u@, an interpretation @f@ and a -- list of rows @rs@. The labels or indices of the record are given by@@ -38,6 +40,22 @@ infixr 5 <+> infixl 8 <<$>> infixl 8 <<*>>++instance TestEquality f => TestEquality (Rec f) where+ testEquality RNil RNil = Just Refl+ testEquality (x :& xs) (y :& ys) = do+ Refl <- testEquality x y+ Refl <- testEquality xs ys+ Just Refl+ testEquality _ _ = Nothing++instance TestCoercion f => TestCoercion (Rec f) where+ testCoercion RNil RNil = Just Coercion+ testCoercion (x :& xs) (y :& ys) = do+ Coercion <- testCoercion x y+ Coercion <- testCoercion xs ys+ Just Coercion+ testCoercion _ _ = Nothing -- | Two records may be pasted together. rappend
Data/Vinyl/Functor.hs view
@@ -79,6 +79,9 @@ , Storable ) +instance Show a => Show (Const a b) where+ show (Const x) = "(Const "++show x ++")"+ instance (Functor f, Functor g) => Functor (Compose f g) where fmap f (Compose x) = Compose (fmap (fmap f) x)
tests/Intro.lhs view
@@ -36,7 +36,7 @@ > data Fields = Name | Age | Sleeping | Master deriving Show Any record can be now described by a type-level list of these labels.-The `DataKinds` extension must be enabled to autmatically turn all the+The `DataKinds` extension must be enabled to automatically turn all the constructors of the `Field` type into types. > type LifeForm = [Name, Age, Sleeping]@@ -155,7 +155,7 @@ > upcastedTucker = rcast tucker The subtyping relationship between record types is expressed with the-`(<:)` constraint; so, rcast is of the following type:+`(<:)` constraint; so, `rcast` is of the following type: < rcast :: r1 <: r2 => Rec f r1 -> Rec f r2
vinyl.cabal view
@@ -1,5 +1,5 @@ name: vinyl-version: 0.5.2+version: 0.5.3 synopsis: Extensible Records -- description: license: MIT