packages feed

composite-cassava 0.0.3.0 → 0.0.3.1

raw patch · 3 files changed

+50/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -1,3 +1,41 @@ # composite-cassava  Provides `FromNamedRecord` and `ToNamedRecord` instances for composite records.++In order to use this, use DerivingVia with one of the newtypes, depending on your+use case. The recommended way is like so:++```{.haskell}+withLensesAndProxies+  [d|+    type A = "A" :-> Text++    type B = "B" :-> Double++    type C = "C" :-> Text++    type D = "D" :-> Int+    |]++type RecMaybe = Rec Maybe '[A, B, C, D]++deriving newtype instance FromField A++deriving newtype instance FromField B++deriving newtype instance FromField C++deriving newtype instance FromField D++deriving newtype instance ToField A++deriving newtype instance ToField B++deriving newtype instance ToField C++deriving newtype instance ToField D++deriving via (TF Maybe '[A, B, C, D]) instance FromNamedRecord RecMaybe++deriving via (TF Maybe '[A, B, C, D]) instance ToNamedRecord RecMaybe+```
composite-cassava.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           composite-cassava-version:        0.0.3.0+version:        0.0.3.1 synopsis:       Csv parsing functionality for composite. description:    Csv parsing functionality for composite. category:       Composite, Csv
src/Composite/Csv.hs view
@@ -28,6 +28,10 @@ instance ToNamedRecord (TF f '[]) where   toNamedRecord m = mempty +-- Newtype helper for DerivingVia `FromNamedRecord` and `ToNamedRecord`. This uses the `FromField` instance+-- on the underlying a in (s :-> a). For the alternative derivation, see `TF`.+--+-- @since 0.0.2.0 newtype F f xs = F {unF :: Rec f xs}  instance (Functor f, KnownSymbol s, FromField (f x), FromNamedRecord (F f xs)) => FromNamedRecord (F f ((s :-> x) ': xs)) where@@ -39,6 +43,10 @@ instance (Functor f, KnownSymbol s, ToField (f x), ToNamedRecord (F f xs)) => ToNamedRecord (F f ((s :-> x) ': xs)) where   toNamedRecord (F (x :^: xs)) = HM.singleton (T.encodeUtf8 (valName @s undefined)) (toField x) <> toNamedRecord (F xs) +-- Newtype helper for DerivingVia `FromNamedRecord` and `ToNamedRecord`. This uses the `FromField` instance on the+-- (s :-> a) field declared as a whole. For the alternative derivation, see `F`.+--+-- @since 0.0.2.0 newtype TF f xs = TF {unTF :: Rec f xs}  instance (Functor f, KnownSymbol s, FromField (f (s :-> x)), FromNamedRecord (TF f xs)) => FromNamedRecord (TF f ((s :-> x) ': xs)) where@@ -50,6 +58,9 @@ instance (Functor f, KnownSymbol s, ToField (f (s :-> x)), ToNamedRecord (TF f xs)) => ToNamedRecord (TF f ((s :-> x) ': xs)) where   toNamedRecord (TF (x :& xs)) = HM.singleton (T.encodeUtf8 (valName @s undefined)) (toField x) <> toNamedRecord (TF xs) +-- | Extracts a `Header` from a composite `Rec` using the symbol names.+--+-- @since 0.0.3.0 class ToHeader x where   extractRecHeader :: Proxy x -> Vector Name