superrecord 0.5.0.1 → 0.5.1.0
raw patch · 4 files changed
+18/−10 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- SuperRecord: instance (GHC.TypeLits.KnownSymbol l, Data.Aeson.Types.FromJSON.FromJSON t, SuperRecord.RecJsonParse lts, SuperRecord.RecSize lts ~ s, GHC.TypeNats.KnownNat s, SuperRecord.KeyDoesNotExist l lts) => SuperRecord.RecJsonParse ((l SuperRecord.Field.:= t) : lts)
- SuperRecord: instance (SuperRecord.Has l lts t, t ~ SuperRecord.RecDeepTy (SuperRecord.Field.FldProxy l) lts) => SuperRecord.RecApplyPath (SuperRecord.Field.FldProxy l) lts
- SuperRecord: instance (SuperRecord.RecDeepTy (l SuperRecord.:& more) lts ~ SuperRecord.RecDeepTy more rts, SuperRecord.RecTy l lts ~ SuperRecord.Rec rts, SuperRecord.Has l lts v, v ~ SuperRecord.Rec rts, SuperRecord.RecApplyPath more rts) => SuperRecord.RecApplyPath (l SuperRecord.:& more) lts
- SuperRecord: instance (SuperRecord.RecSize lts ~ s, GHC.TypeNats.KnownNat s, SuperRecord.RecJsonParse lts) => Data.Aeson.Types.FromJSON.FromJSON (SuperRecord.Rec lts)
- SuperRecord: instance GHC.TypeLits.KnownSymbol name => SuperRecord.FromNative (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Base.Just name) p s l) (GHC.Generics.Rec0 t)) '[name SuperRecord.Field.:= t]
- SuperRecord: instance SuperRecord.Has name lts t => SuperRecord.ToNative (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Base.Just name) p s l) (GHC.Generics.Rec0 t)) lts
- SuperRecord: instance forall k (l :: k -> *) (lhs :: [*]) (r :: k -> *) (rhs :: [*]) (lts :: [*]). (SuperRecord.FromNative l lhs, SuperRecord.FromNative r rhs, lts ~ SuperRecord.Sort (SuperRecord.RecAppend lhs rhs), SuperRecord.RecCopy lhs lhs lts, SuperRecord.RecCopy rhs rhs lts, GHC.TypeNats.KnownNat (SuperRecord.RecSize lhs), GHC.TypeNats.KnownNat (SuperRecord.RecSize rhs), GHC.TypeNats.KnownNat (SuperRecord.RecSize lhs GHC.TypeNats.+ SuperRecord.RecSize rhs)) => SuperRecord.FromNative (l GHC.Generics.:*: r) lts
+ SuperRecord: infix 6 :=
+ SuperRecord: instance (GHC.TypeLits.KnownSymbol l, Data.Aeson.Types.FromJSON.FromJSON t, SuperRecord.RecJsonParse lts, SuperRecord.RecSize lts Data.Type.Equality.~ s, GHC.TypeNats.KnownNat s, SuperRecord.KeyDoesNotExist l lts) => SuperRecord.RecJsonParse ((l SuperRecord.Field.:= t) : lts)
+ SuperRecord: instance (SuperRecord.Has l lts t, t Data.Type.Equality.~ SuperRecord.RecDeepTy (SuperRecord.Field.FldProxy l) lts) => SuperRecord.RecApplyPath (SuperRecord.Field.FldProxy l) lts
+ SuperRecord: instance (SuperRecord.RecDeepTy (l SuperRecord.:& more) lts Data.Type.Equality.~ SuperRecord.RecDeepTy more rts, SuperRecord.RecTy l lts Data.Type.Equality.~ SuperRecord.Rec rts, SuperRecord.Has l lts v, v Data.Type.Equality.~ SuperRecord.Rec rts, SuperRecord.RecApplyPath more rts) => SuperRecord.RecApplyPath (l SuperRecord.:& more) lts
+ SuperRecord: instance (SuperRecord.RecSize lts Data.Type.Equality.~ s, GHC.TypeNats.KnownNat s, SuperRecord.RecJsonParse lts) => Data.Aeson.Types.FromJSON.FromJSON (SuperRecord.Rec lts)
+ SuperRecord: instance GHC.TypeLits.KnownSymbol name => SuperRecord.FromNative (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Maybe.Just name) p s l) (GHC.Generics.Rec0 t)) '[name SuperRecord.Field.:= t]
+ SuperRecord: instance SuperRecord.Has name lts t => SuperRecord.ToNative (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Maybe.Just name) p s l) (GHC.Generics.Rec0 t)) lts
+ SuperRecord: instance forall k (l :: k -> *) (lhs :: [*]) (r :: k -> *) (rhs :: [*]) (lts :: [*]). (SuperRecord.FromNative l lhs, SuperRecord.FromNative r rhs, lts Data.Type.Equality.~ SuperRecord.Sort (SuperRecord.RecAppend lhs rhs), SuperRecord.RecCopy lhs lhs lts, SuperRecord.RecCopy rhs rhs lts, GHC.TypeNats.KnownNat (SuperRecord.RecSize lhs), GHC.TypeNats.KnownNat (SuperRecord.RecSize rhs), GHC.TypeNats.KnownNat (SuperRecord.RecSize lhs GHC.TypeNats.+ SuperRecord.RecSize rhs)) => SuperRecord.FromNative (l GHC.Generics.:*: r) lts
+ SuperRecord: type RecVecIdxPos l lts = RecSize lts - RecTyIdxH 0 l lts - 1
+ SuperRecord: unsafeRCons :: forall l t lts s. (RecSize lts ~ s, KnownNat s, KeyDoesNotExist l lts) => (l := t) -> Rec lts -> Rec ((l := t) : lts)
+ SuperRecord: unsafeRNil :: Int -> Rec '[]
+ SuperRecord.Variant: type family VariantMember a opts
+ SuperRecord.Variant.Text: type family TextVariantMember (lbl :: Symbol) (opts :: [Symbol])
- SuperRecord: (&) :: forall l t lts s sortedLts. (RecSize lts ~ s, sortedLts ~ Sort (l := t : lts), KnownNat s, KnownNat (RecVecIdxPos l sortedLts), KeyDoesNotExist l lts, RecCopy lts lts sortedLts) => l := t -> Rec lts -> Rec sortedLts
+ SuperRecord: (&) :: forall l t lts s sortedLts. (RecSize lts ~ s, sortedLts ~ Sort ((l := t) : lts), KnownNat s, KnownNat (RecVecIdxPos l sortedLts), KeyDoesNotExist l lts, RecCopy lts lts sortedLts) => (l := t) -> Rec lts -> Rec sortedLts
- SuperRecord: (&.) :: forall l v lts. (Has l lts v) => Rec lts -> FldProxy l -> v
+ SuperRecord: (&.) :: forall l v lts. Has l lts v => Rec lts -> FldProxy l -> v
- SuperRecord: data label (:=) value
+ SuperRecord: data label := value
- SuperRecord: data lbl (:&) more
+ SuperRecord: data lbl :& more
- SuperRecord: get :: forall l v lts. (Has l lts v) => FldProxy l -> Rec lts -> v
+ SuperRecord: get :: forall l v lts. Has l lts v => FldProxy l -> Rec lts -> v
- SuperRecord: modify :: forall l v lts. (Has l lts v) => FldProxy l -> (v -> v) -> Rec lts -> Rec lts
+ SuperRecord: modify :: forall l v lts. Has l lts v => FldProxy l -> (v -> v) -> Rec lts -> Rec lts
- SuperRecord: rcons :: forall l t lts s sortedLts. (RecSize lts ~ s, sortedLts ~ Sort (l := t : lts), KnownNat s, KnownNat (RecVecIdxPos l sortedLts), KeyDoesNotExist l lts, RecCopy lts lts sortedLts) => l := t -> Rec lts -> Rec sortedLts
+ SuperRecord: rcons :: forall l t lts s sortedLts. (RecSize lts ~ s, sortedLts ~ Sort ((l := t) : lts), KnownNat s, KnownNat (RecVecIdxPos l sortedLts), KeyDoesNotExist l lts, RecCopy lts lts sortedLts) => (l := t) -> Rec lts -> Rec sortedLts
- SuperRecord: recToEncoding :: forall lts. (RecApply lts lts ToJSON) => Rec lts -> Encoding
+ SuperRecord: recToEncoding :: forall lts. RecApply lts lts ToJSON => Rec lts -> Encoding
- SuperRecord: recToValue :: forall lts. (RecApply lts lts ToJSON) => Rec lts -> Value
+ SuperRecord: recToValue :: forall lts. RecApply lts lts ToJSON => Rec lts -> Value
- SuperRecord: reflectRec :: forall c r lts. (RecApply lts lts c) => Proxy c -> (forall a. c a => String -> a -> r) -> Rec lts -> [r]
+ SuperRecord: reflectRec :: forall c r lts. RecApply lts lts c => Proxy c -> (forall a. c a => String -> a -> r) -> Rec lts -> [r]
- SuperRecord: reflectRecFold :: forall c r lts. (RecApply lts lts c) => Proxy c -> (forall a. c a => String -> a -> r -> r) -> Rec lts -> r -> r
+ SuperRecord: reflectRecFold :: forall c r lts. RecApply lts lts c => Proxy c -> (forall a. c a => String -> a -> r -> r) -> Rec lts -> r -> r
- SuperRecord: set :: forall l v lts. (Has l lts v) => FldProxy l -> v -> Rec lts -> Rec lts
+ SuperRecord: set :: forall l v lts. Has l lts v => FldProxy l -> v -> Rec lts -> Rec lts
- SuperRecord: showRec :: forall lts. (RecApply lts lts Show) => Rec lts -> [(String, String)]
+ SuperRecord: showRec :: forall lts. RecApply lts lts Show => Rec lts -> [(String, String)]
- SuperRecord: type family RecKeysT lts :: [Symbol];
+ SuperRecord: type family KeyDoesNotExist (l :: Symbol) (lts :: [*]) :: Constraint
Files
- CHANGELOG.md +4/−0
- README.md +1/−1
- src/SuperRecord.hs +11/−7
- superrecord.cabal +2/−2
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.5.1.0++* Exported `unsafeRNil` and `unsafeRCons`.+ # 0.5.0.1 * GHC 8.6 pre-release compatibility (h/t @galenhuntington)
README.md view
@@ -6,4 +6,4 @@ Supercharged (fast!) anonymous records and variants (open sums) for Haskell. -For an introduction to anonymous records read [this blog post](https://www.athiemann.net/2017/07/02/superrecord.html).+For an introduction to anonymous records read [this blog post](https://www.athiemann.net/2017/07/02/superrecord.html) or watch [this talk](https://www.youtube.com/watch?v=Nh0XD2hPV8w).
src/SuperRecord.hs view
@@ -55,11 +55,15 @@ , recToValue, recToEncoding , recJsonParser, RecJsonParse(..) , RecNfData(..)+ , RecVecIdxPos , RecSize, RemoveAccessTo , FldProxy(..), RecDeepTy , RecAll , KeyDoesNotExist , Sort+ -- * Unsafe operations+ , unsafeRNil+ , unsafeRCons ) where @@ -148,23 +152,23 @@ -- | An empty record rnil :: Rec '[]-rnil = unsafeRnil 0+rnil = unsafeRNil 0 {-# INLINE rnil #-} -- | An empty record with an initial size for the record-unsafeRnil :: Int -> Rec '[]+unsafeRNil :: Int -> Rec '[] #ifndef JS_RECORD-unsafeRnil (I# n#) =+unsafeRNil (I# n#) = runST' $ ST $ \s# -> case newSmallArray# n# (error "No Value") s# of (# s'#, arr# #) -> case unsafeFreezeSmallArray# arr# s'# of (# s''#, a# #) -> (# s''# , Rec a# #) #else-unsafeRnil _ =+unsafeRNil _ = unsafePerformIO $! Rec <$> JS.create #endif-{-# INLINE unsafeRnil #-}+{-# INLINE unsafeRNil #-} -- | Prepend a record entry to a record 'Rec' rcons ::@@ -234,7 +238,7 @@ s'# -> recCopyInto pNext lts prxy tgt# s'# -- | Prepend a record entry to a record 'Rec'. Assumes that the record was created with--- 'unsafeRnil' and still has enough free slots, mutates the original 'Rec' which should+-- 'unsafeRNil' and still has enough free slots, mutates the original 'Rec' which should -- not be reused after unsafeRCons :: forall l t lts s.@@ -670,7 +674,7 @@ recJsonParse :: Int -> Object -> Parser (Rec lts) instance RecJsonParse '[] where- recJsonParse initSize _ = pure (unsafeRnil initSize)+ recJsonParse initSize _ = pure (unsafeRNil initSize) instance ( KnownSymbol l, FromJSON t, RecJsonParse lts
superrecord.cabal view
@@ -1,5 +1,5 @@ name: superrecord-version: 0.5.0.1+version: 0.5.1.0 synopsis: Supercharged anonymous records description: Anonymous records with various useful utilities homepage: https://github.com/agrafix/superrecord#readme@@ -8,7 +8,7 @@ author: Alexander Thiemann maintainer: mail@athiemann.net copyright: 2017-2018 Alexander Thiemann <mail@athiemann.net>-category: Web+category: Records build-type: Simple extra-source-files: README.md