packages feed

extensible 0.2.5 → 0.2.6

raw patch · 7 files changed

+79/−5 lines, 7 files

Files

+ CHANGELOG.md view
@@ -0,0 +1,45 @@+0.2.6+-----------------------------------------------------+* Right-associated `(++)`+* Added `htrans`+* Added `recordType`+* Made Eq, Ord, Show instances for Position more reasonable++0.2.5+-----------------------------------------------------+* Added `(<:)`+* Re-exported `Data.Extensible.Record`, `Data.Extensible.Union`, `Data.Extensible.League`+* Brushed instances up+* Added `subset`+* Added `Data.Extensible.Internal.HList` and combinators++0.2.4+------------------------------------------------------+* Corrected the definition of `Half`+* Added `coinclusion`, `wrench`, `retrench` along with `Nullable`+* Added `htabulate`++0.2.3+-------------------------------------------------------+* Corrected the behavior of `Generate` and `Forall`+* Made type errors more readable+* Added `(*++*)`+* Fixed the accidental miscall of `getUnion`++0.2.2+--------------------------------------------------------+* Added `recordAt`+* Added `ord`+* Re-added `K1`+* Toggled INLINE pragmas++0.2.1+--------------------------------------------------------+* Added `hhead` and `htail`+* Changed the definition of `Union` to use coyoneda style++0.2+--------------------------------------------------------+* Split modules up+* Flipped `Position`+* Added several combinators
examples/records.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell, DataKinds, TypeOperators, KindSignatures, TypeFamilies, FlexibleContexts #-}+{-# LANGUAGE TemplateHaskell, DataKinds, TypeOperators, TypeFamilies, FlexibleContexts #-} import Data.Extensible.Record import Data.Extensible import Control.Lens
extensible.cabal view
@@ -1,5 +1,5 @@ name:                extensible-version:             0.2.5+version:             0.2.6 synopsis:            Extensible, efficient, lens-friendly data types homepage:            https://github.com/fumieval/extensible bug-reports:         http://github.com/fumieval/extensible/issues@@ -18,6 +18,7 @@   .gitignore   .travis.yml   README.md+  CHANGELOG.md cabal-version:       >=1.10  source-repository head
src/Data/Extensible/Inclusion.hs view
@@ -78,7 +78,9 @@ -- | Extend a product and fill missing fields by 'Null'. wrench :: (Generate ys, xs ⊆ ys) => h :* xs -> Nullable h :* ys wrench xs = mapNullable (flip hlookup xs) `hmap` coinclusion+{-# INLINE wrench #-}  -- | Narrow the range of the sum, if possible. retrench :: (Generate ys, xs ⊆ ys) => h :| ys -> Nullable ((:|) h) xs retrench (UnionAt pos h) = flip UnionAt h `mapNullable` hlookup pos coinclusion+{-# INLINE retrench #-}
src/Data/Extensible/Internal.hs view
@@ -66,8 +66,17 @@     $ conT ''Position `appT` pure t `appT` varT (names !! n)  -- | The position of @x@ in the type level set @xs@.-newtype Position (xs :: [k]) (x :: k) = Position Int deriving (Show, Eq, Ord, Typeable)+newtype Position (xs :: [k]) (x :: k) = Position Int deriving Typeable +instance Show (Position xs x) where+  show (Position n) = "$(ord " ++ show n ++ ")"++instance Eq (Position xs x) where+  _ == _ = True++instance Ord (Position xs x) where+  compare _ _ = EQ+ -- | Embodies a type equivalence to ensure that the 'Position' points the first element. runPosition :: Position (y ': xs) x -> Either (x :~: y) (Position xs x) runPosition (Position 0) = Left (unsafeCoerce Refl)@@ -195,6 +204,8 @@ type family (++) (xs :: [k]) (ys :: [k]) :: [k] where   '[] ++ ys = ys   (x ': xs) ++ ys = x ': xs ++ ys++infixr 5 ++  type family Concat (xs :: [[k]]) :: [k] where   Concat '[] = '[]
src/Data/Extensible/Product.hs view
@@ -22,6 +22,7 @@   , htail   , huncons   , hmap+  , htrans   , hzipWith   , hzipWith3   , hfoldMap@@ -47,8 +48,8 @@ data (h :: k -> *) :* (s :: [k]) where   Nil :: h :* '[]   Tree :: !(h x)-    -> !(h :* Half xs)-    -> !(h :* Half (Tail xs))+    -> h :* Half xs+    -> h :* Half (Tail xs)     -> h :* (x ': xs)  deriving instance Typeable (:*)@@ -85,6 +86,11 @@ hmap :: (forall x. g x -> h x) -> g :* xs -> h :* xs hmap t (Tree h a b) = Tree (t h) (hmap t a) (hmap t b) hmap _ Nil = Nil++-- | Transform every elements in a product, preserving the order.+htrans :: (forall x. g x -> h (t x)) -> g :* xs -> h :* Map t xs+htrans t (Tree h a b) = unsafeCoerce (Tree (t h)) (htrans t a) (htrans t b)+htrans _ Nil = Nil  -- | Combine products. (*++*) :: h :* xs -> h :* ys -> h :* (xs ++ ys)
src/Data/Extensible/Record.hs view
@@ -20,6 +20,7 @@   , (:*)(Nil)   , (@=)   , mkField+  , recordType   , Field(..)   , FieldValue   , FieldLens@@ -31,6 +32,7 @@ import Data.Extensible.Product import Data.Extensible.Internal import Language.Haskell.TH+import Language.Haskell.TH.Quote import GHC.TypeLits hiding (Nat) import Data.Extensible.Inclusion import Data.Extensible.Dictionary ()@@ -110,3 +112,10 @@     , funD (mkName s) [clause [varP f] (normalB $ varE 'sector `appE` wf) []]     , return $ PragmaD $ InlineP (mkName s) Inline FunLike AllPhases     ]++recordType :: QuasiQuoter+recordType = QuasiQuoter { quoteType = appT (conT ''Record) . foldr (\e t -> promotedConsT `appT` e `appT` t)+promotedNilT . map (litT . strTyLit) . words+  , quoteDec = error "Unsupported"+  , quoteExp = error "Unsupported"+  , quotePat = error "Unsupported" }