vinyl 0.9.1 → 0.9.2
raw patch · 8 files changed
+63/−16 lines, 8 files
Files
- CHANGELOG.md +4/−0
- Data/Vinyl/Class/Method.hs +15/−12
- Data/Vinyl/Core.hs +2/−0
- Data/Vinyl/Curry.hs +28/−0
- Data/Vinyl/Functor.hs +2/−0
- tests/Intro.lhs +1/−0
- tests/doctests.hs +6/−0
- vinyl.cabal +5/−4
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.9.2++- Add `runcurryX` for applying an uncurried function to a `Rec` passing through the `XRec` machinery to strip out syntactic noise.+ # 0.9.0 - A new `SRec` type for constant time field access for records with densely packed `Storable` fields. Conversion from `Rec` is accomplished with `toSRec`, while `fromSRec` takes you back to `Rec`. Record updates are fairly slow compared to native Haskell records and even `Rec`, but reading a field is as fast as anything.
Data/Vinyl/Class/Method.hs view
@@ -1,18 +1,19 @@-{-# LANGUAGE AllowAmbiguousTypes #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-}-{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE BangPatterns #-}-{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-} {-| This module uses 'RecAll' to extend common typeclass methods to records. Generally, it is preferable to use the original typeclass methods to these@@ -57,7 +58,9 @@ import Data.Vinyl.Derived (FieldRec) import Data.Vinyl.Functor ((:.), ElField(..)) import Data.Vinyl.TypeLevel+#if __GLASGOW_HASKELL__ < 804 import Data.Monoid+#endif recEq :: RecAll f rs Eq => Rec f rs -> Rec f rs -> Bool recEq RNil RNil = True
Data/Vinyl/Core.hs view
@@ -32,7 +32,9 @@ module Data.Vinyl.Core where import Data.Monoid (Monoid)+#if __GLASGOW_HASKELL__ < 804 import Data.Semigroup+#endif import Foreign.Ptr (castPtr, plusPtr) import Foreign.Storable (Storable(..)) import Data.Vinyl.Functor
Data/Vinyl/Curry.hs view
@@ -14,6 +14,7 @@ import Data.Vinyl import Data.Vinyl.Functor+import Data.Vinyl.XRec -- * Currying @@ -100,6 +101,20 @@ runcurry' f (Identity x :& xs) = runcurry' (f x) xs {-# INLINABLE runcurry' #-} +-- | Apply an uncurried function to an 'XRec'.+xruncurry :: CurriedX f ts a -> XRec f ts -> a+xruncurry x RNil = x+xruncurry f (x :& xs) = xruncurry (f (unX x)) xs+{-# INLINABLE xruncurry #-}++-- | Apply an uncurried function to a 'Rec' like 'runcurry' except the+-- function enjoys a type simplified by the 'XData' machinery that+-- strips away type-induced noise like 'Identity', 'Compose', and+-- 'ElField'.+runcurryX :: IsoXRec f ts => CurriedX f ts a -> Rec f ts -> a+runcurryX f = xruncurry f . toXRec+{-# INLINE runcurryX #-}+ -- * Applicative Combinators {-|@@ -155,3 +170,16 @@ type family CurriedF (f :: u -> *) (ts :: [u]) a where CurriedF f '[] a = a CurriedF f (t ': ts) a = f t -> CurriedF f ts a++{-|+For the type-level list @ts@, @'CurriedX' f ts a@ is a curried function type+from arguments of type @HKD f t@ for @t@ in @ts@, to a result of type @a@.++>>> :set -XTypeOperators+>>> :kind! CurriedX (Maybe :. Identity) '[Int, Bool, String] Int+CurriedX (Maybe :. Identity) '[Int, Bool, String] Int :: *+= Maybe Int -> Maybe Bool -> Maybe [Char] -> Int+-}+type family CurriedX (f :: u -> *) (ts :: [u]) a where+ CurriedX f '[] a = a+ CurriedX f (t ': ts) a = HKD f t -> CurriedX f ts a
Data/Vinyl/Functor.hs view
@@ -32,7 +32,9 @@ ) where import Data.Proxy+#if __GLASGOW_HASKELL__ < 804 import Data.Semigroup+#endif import Foreign.Ptr (castPtr) import Foreign.Storable import GHC.TypeLits
tests/Intro.lhs view
@@ -21,6 +21,7 @@ > {-# LANGUAGE FlexibleContexts, FlexibleInstances, NoMonomorphismRestriction #-} > {-# LANGUAGE GADTs, TypeSynonymInstances, TemplateHaskell, StandaloneDeriving #-} > {-# LANGUAGE TypeApplications #-}+> module Intro where > import Data.Vinyl > import Data.Vinyl.Functor > import Control.Lens hiding (Identity)
+ tests/doctests.hs view
@@ -0,0 +1,6 @@+import Test.DocTest++main :: IO ()+main = doctest [ "tests/Intro.lhs"+ , "Data/Vinyl/Functor.hs"+ , "Data/Vinyl/Curry.hs" ]
vinyl.cabal view
@@ -1,5 +1,5 @@ name: vinyl-version: 0.9.1+version: 0.9.2 synopsis: Extensible Records -- description: license: MIT@@ -12,7 +12,7 @@ build-type: Simple cabal-version: >=1.10 extra-source-files: CHANGELOG.md-tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1+tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3 description: Extensible records for Haskell with lenses. @@ -80,8 +80,9 @@ test-suite doctests type: exitcode-stdio-1.0 hs-source-dirs: tests- main-is: Intro.lhs- build-depends: base >= 4.7 && <= 5, lens, vinyl, doctest >= 0.8, singletons >= 0.10+ other-modules: Intro+ main-is: doctests.hs+ build-depends: base >= 4.7 && <= 5, lens, doctest >= 0.8, singletons >= 0.10, vinyl default-language: Haskell2010 test-suite spec