packages feed

knit 0.3.0.0 → 0.4.0.0

raw patch · 2 files changed

+10/−20 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Generics.Eot: --
- Generics.Eot: -- </pre>
- Generics.Eot: -- </ul>
- Generics.Eot: -- <a>Either</a>s.</li>
- Generics.Eot: -- <li>Again there's always an end-marker, this time of type <tt>()</tt>.
- Generics.Eot: -- <li>The fields of one constructor are mapped to right-nested
- Generics.Eot: -- <li>There's always a so-called end-marker <a>Void</a>. It's an invalid
- Generics.Eot: -- <pre>
- Generics.Eot: -- <ul>
- Generics.Eot: -- A constructor with three fields <tt>a</tt>, <tt>b</tt>, <tt>c</tt> is
- Generics.Eot: -- Either (Int, (Bool, ())) (Either (String, ()) Void)
- Generics.Eot: -- These rules (and the end-markers) are necessary to make sure generic
- Generics.Eot: -- accidentally create such a value). So e.g. <tt>data Foo = A</tt> would
- Generics.Eot: -- be mapped to <tt>Either () Void</tt>, and a type with no constructors
- Generics.Eot: -- choice (and <a>Void</a> is uninhabited to make sure you don't
- Generics.Eot: -- data Foo = A Int Bool | B String
- Generics.Eot: -- end-marker).</li>
- Generics.Eot: -- field types and which parts belong to the generic skeleton.
- Generics.Eot: -- functions know exactly which parts of the generic representation are
- Generics.Eot: -- is mapped to <tt>Void</tt>.</li>
- Generics.Eot: -- isomorphic generic representations. Here's an example:
- Generics.Eot: -- mapped to <tt>(a, (b, (c, ())))</tt>, one field <tt>a</tt> is mapped
- Generics.Eot: -- to <tt>(a, ())</tt>, and no fields are mapped to <tt>()</tt> (just the
- Generics.Eot: -- tuples.</li>
- Generics.Eot: -- would be mapped to:
- Generics.Eot: -- | <a>Eot</a> is a type level function that maps arbitrary ADTs to
- Generics.Eot: Constructor :: String -> Fields -> Constructor
- Generics.Eot: Datatype :: String -> [Constructor] -> Datatype
- Generics.Eot: Named :: field -> Named (a :: Symbol) field
- Generics.Eot: NoFields :: Fields
- Generics.Eot: NoSelectors :: Int -> Fields
- Generics.Eot: Proxy :: Proxy (t :: k)
- Generics.Eot: Selectors :: [String] -> Fields
- Generics.Eot: [constructorName] :: Constructor -> String
- Generics.Eot: [constructors] :: Datatype -> [Constructor]
- Generics.Eot: [datatypeName] :: Datatype -> String
- Generics.Eot: [fields] :: Constructor -> Fields
- Generics.Eot: absurd :: Void -> a
- Generics.Eot: class Generic a
- Generics.Eot: class HasEot a where {
- Generics.Eot: data Constructor
- Generics.Eot: data Datatype
- Generics.Eot: data Fields
- Generics.Eot: data Named (a :: Symbol) field
- Generics.Eot: data Proxy (t :: k)
- Generics.Eot: data Void
- Generics.Eot: datatype :: HasEot a => Proxy a -> Datatype
- Generics.Eot: fromEot :: HasEot a => Eot a -> a
- Generics.Eot: instance (GHC.Generics.Generic a, Generics.Eot.ImpliedByGeneric a c f) => Generics.Eot.HasEot a
- Generics.Eot: toEot :: HasEot a => a -> Eot a
- Generics.Eot: type family Eot a :: *;
- Generics.Eot: }
- Generics.Eot.Datatype: Constructor :: String -> Fields -> Constructor
- Generics.Eot.Datatype: Datatype :: String -> [Constructor] -> Datatype
- Generics.Eot.Datatype: NoFields :: Fields
- Generics.Eot.Datatype: NoSelectors :: Int -> Fields
- Generics.Eot.Datatype: Selectors :: [String] -> Fields
- Generics.Eot.Datatype: [constructorName] :: Constructor -> String
- Generics.Eot.Datatype: [constructors] :: Datatype -> [Constructor]
- Generics.Eot.Datatype: [datatypeName] :: Datatype -> String
- Generics.Eot.Datatype: [fields] :: Constructor -> Fields
- Generics.Eot.Datatype: class GenericConstructors (a :: * -> *)
- Generics.Eot.Datatype: class GenericDatatype (a :: * -> *)
- Generics.Eot.Datatype: class GenericFields (a :: * -> *)
- Generics.Eot.Datatype: data Constructor
- Generics.Eot.Datatype: data Datatype
- Generics.Eot.Datatype: data Fields
- Generics.Eot.Datatype: datatypeC :: GenericDatatype a => Proxy a -> Datatype
- Generics.Eot.Datatype: getConstructors :: GenericConstructors a => Proxy a -> [Constructor]
- Generics.Eot.Datatype: getField :: forall c f. Selector c => Proxy (S1 c (Rec0 f)) -> Maybe String
- Generics.Eot.Datatype: getFields :: GenericFields a => Proxy a -> Fields
- Generics.Eot.Datatype: getFieldsC :: GenericFields a => Proxy a -> [Maybe String]
- Generics.Eot.Datatype: instance (GHC.Generics.Constructor c, Generics.Eot.Datatype.GenericFields f) => Generics.Eot.Datatype.GenericConstructors (GHC.Generics.C1 c f)
- Generics.Eot.Datatype: instance (GHC.Generics.Datatype c, Generics.Eot.Datatype.GenericConstructors f) => Generics.Eot.Datatype.GenericDatatype (GHC.Generics.D1 c f)
- Generics.Eot.Datatype: instance (Generics.Eot.Datatype.GenericConstructors a, Generics.Eot.Datatype.GenericConstructors b) => Generics.Eot.Datatype.GenericConstructors (a GHC.Generics.:+: b)
- Generics.Eot.Datatype: instance (Generics.Eot.Datatype.GenericFields a, Generics.Eot.Datatype.GenericFields b) => Generics.Eot.Datatype.GenericFields (a GHC.Generics.:*: b)
- Generics.Eot.Datatype: instance GHC.Classes.Eq Generics.Eot.Datatype.Constructor
- Generics.Eot.Datatype: instance GHC.Classes.Eq Generics.Eot.Datatype.Datatype
- Generics.Eot.Datatype: instance GHC.Classes.Eq Generics.Eot.Datatype.Fields
- Generics.Eot.Datatype: instance GHC.Generics.Selector c => Generics.Eot.Datatype.GenericFields (GHC.Generics.S1 c (GHC.Generics.Rec0 f))
- Generics.Eot.Datatype: instance GHC.Show.Show Generics.Eot.Datatype.Constructor
- Generics.Eot.Datatype: instance GHC.Show.Show Generics.Eot.Datatype.Datatype
- Generics.Eot.Datatype: instance GHC.Show.Show Generics.Eot.Datatype.Fields
- Generics.Eot.Datatype: instance Generics.Eot.Datatype.GenericConstructors GHC.Generics.V1
- Generics.Eot.Datatype: instance Generics.Eot.Datatype.GenericFields GHC.Generics.U1
- Generics.Eot.Eot: Named :: field -> Named (a :: Symbol) field
- Generics.Eot.Eot: class HasEotG (a :: * -> *) where {
- Generics.Eot.Eot: data Named (a :: Symbol) field
- Generics.Eot.Eot: fromEotG :: HasEotG a => EotG a -> a x
- Generics.Eot.Eot: instance (Generics.Eot.Eot.HasConstructorsG a, Generics.Eot.Eot.HasConstructorsG b, Generics.Eot.Eot.Normalize (Generics.Eot.Eot.Constructors a) (Generics.Eot.Eot.Constructors b)) => Generics.Eot.Eot.HasConstructorsG (a GHC.Generics.:+: b)
- Generics.Eot.Eot: instance (Generics.Eot.Eot.HasFieldsG a, Generics.Eot.Eot.HasFieldsG b, Generics.Eot.Eot.Concat (Generics.Eot.Eot.Fields a) (Generics.Eot.Eot.Fields b)) => Generics.Eot.Eot.HasFieldsG (a GHC.Generics.:*: b)
- Generics.Eot.Eot: instance GHC.Show.Show field => GHC.Show.Show (Generics.Eot.Eot.Named a field)
- Generics.Eot.Eot: instance GHC.Show.Show field => GHC.Show.Show (Generics.Eot.Eot.Unnamed field)
- Generics.Eot.Eot: instance GHC.TypeLits.KnownSymbol name => Generics.Eot.Eot.HasFieldsG (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Maybe.Just name) x y z) (GHC.Generics.Rec0 f))
- Generics.Eot.Eot: instance Generics.Eot.Eot.Concat () bs
- Generics.Eot.Eot: instance Generics.Eot.Eot.Concat as bs => Generics.Eot.Eot.Concat (a, as) bs
- Generics.Eot.Eot: instance Generics.Eot.Eot.HasConstructorsG GHC.Generics.V1
- Generics.Eot.Eot: instance Generics.Eot.Eot.HasConstructorsG f => Generics.Eot.Eot.HasEotG (GHC.Generics.D1 c f)
- Generics.Eot.Eot: instance Generics.Eot.Eot.HasFieldsG (GHC.Generics.S1 ('GHC.Generics.MetaSel 'GHC.Maybe.Nothing x y z) (GHC.Generics.Rec0 f))
- Generics.Eot.Eot: instance Generics.Eot.Eot.HasFieldsG GHC.Generics.U1
- Generics.Eot.Eot: instance Generics.Eot.Eot.HasFieldsG f => Generics.Eot.Eot.HasConstructorsG (GHC.Generics.C1 c f)
- Generics.Eot.Eot: instance Generics.Eot.Eot.Normalize Data.Void.Void b
- Generics.Eot.Eot: instance Generics.Eot.Eot.Normalize b c => Generics.Eot.Eot.Normalize (Data.Either.Either a b) c
- Generics.Eot.Eot: toEotG :: HasEotG a => a x -> EotG a
- Generics.Eot.Eot: type family EotG a :: *;
- Generics.Eot.Eot: }
+ Knit: Done :: Mode
+ Knit: Dynamic :: () -> Dynamic
+ Knit: EForeignId :: TableName -> FieldName -> t -> EId
+ Knit: EId :: TableName -> FieldName -> t -> Dynamic -> EId
+ Knit: ERemove :: TableName -> FieldName -> t -> Dynamic -> EId
+ Knit: ForeignId :: t -> ForeignRecordId (table :: Symbol) (field :: Symbol) t
+ Knit: Id :: t -> RecordId t
+ Knit: Lazy :: a tables 'Resolved -> Lazy tables a
+ Knit: MissingIds :: [(TableName, FieldName, FieldValue)] -> ResolveError
+ Knit: Remove :: t -> RecordId t
+ Knit: RepeatingIds :: [(TableName, FieldName, FieldValue)] -> ResolveError
+ Knit: Resolved :: Mode
+ Knit: Unresolved :: Mode
+ Knit: [get] :: Lazy tables a -> a tables 'Resolved
+ Knit: class GGatherIds u
+ Knit: class GGatherTableIds t
+ Knit: class GResolve u r
+ Knit: class GResolveTables u t
+ Knit: class KnitRecord (tables :: Mode -> *) u
+ Knit: class KnitTables t
+ Knit: data EId
+ Knit: data Lazy tables a
+ Knit: data Mode
+ Knit: data RecordId t
+ Knit: data ResolveError
+ Knit: fromDynamic :: Dynamic -> a
+ Knit: gGatherIds :: GGatherIds u => TableName -> Dynamic -> u -> [EId]
+ Knit: gGatherTableIds :: GGatherTableIds t => t -> [(TableName, [[EId]])]
+ Knit: gResolve :: GResolve u r => (TableName -> FieldName -> FieldValue -> Dynamic) -> u -> r
+ Knit: gResolveTables :: GResolveTables u t => [[Bool]] -> (TableName -> FieldName -> FieldValue -> Dynamic) -> u -> t
+ Knit: gatherIds :: (KnitRecord tables u, HasEot (u tables 'Unresolved)) => GGatherIds (Eot (u tables 'Unresolved)) => TableName -> Dynamic -> u tables 'Unresolved -> [EId]
+ Knit: gatherTableIds :: (KnitTables t, HasEot (t 'Unresolved)) => GGatherTableIds (Eot (t 'Unresolved)) => t 'Unresolved -> [(TableName, [[EId]])]
+ Knit: instance (GHC.Show.Show t, Knit.GGatherIds us, Data.Foldable.Foldable f, GHC.TypeLits.KnownSymbol field) => Knit.GGatherIds (Generics.Eot.Eot.Named field (f (Knit.RecordId t)), us)
+ Knit: instance (GHC.Show.Show t, Knit.GGatherIds us, Data.Foldable.Foldable f, GHC.TypeLits.KnownSymbol table, GHC.TypeLits.KnownSymbol field) => Knit.GGatherIds (Generics.Eot.Eot.Named field' (f (Knit.ForeignRecordId table field t)), us)
+ Knit: instance (GHC.Show.Show t, Knit.GGatherIds us, GHC.TypeLits.KnownSymbol field) => Knit.GGatherIds (Generics.Eot.Eot.Named field (Knit.RecordId t), us)
+ Knit: instance (GHC.Show.Show t, Knit.GGatherIds us, GHC.TypeLits.KnownSymbol table, GHC.TypeLits.KnownSymbol field) => Knit.GGatherIds (Generics.Eot.Eot.Named field' (Knit.ForeignRecordId table field t), us)
+ Knit: instance (GHC.Show.Show u, Knit.KnitRecord tables r, Knit.GResolve us rs, GHC.Base.Functor f, GHC.TypeLits.KnownSymbol table, GHC.TypeLits.KnownSymbol field) => Knit.GResolve (Generics.Eot.Eot.Named x (f (Knit.ForeignRecordId table field u)), us) (Generics.Eot.Eot.Named x (f (Knit.Lazy tables r)), rs)
+ Knit: instance (GHC.Show.Show u, Knit.KnitRecord tables r, Knit.GResolve us rs, GHC.TypeLits.KnownSymbol table, GHC.TypeLits.KnownSymbol field) => Knit.GResolve (Generics.Eot.Eot.Named x (Knit.ForeignRecordId table field u), us) (Generics.Eot.Eot.Named x (Knit.Lazy tables r), rs)
+ Knit: instance (Knit.GGatherIds u, Knit.GGatherIds v) => Knit.GGatherIds (Data.Either.Either u v)
+ Knit: instance (Knit.GGatherIds us, Data.Foldable.Foldable f, Knit.KnitRecord tables r) => Knit.GGatherIds (Generics.Eot.Eot.Named field (f (r tables 'Knit.Unresolved)), us)
+ Knit: instance (Knit.GGatherIds us, Knit.KnitRecord tables r) => Knit.GGatherIds (Generics.Eot.Eot.Named field (r tables 'Knit.Unresolved), us)
+ Knit: instance (Knit.GGatherTableIds t, Knit.GGatherTableIds u) => Knit.GGatherTableIds (Data.Either.Either t u)
+ Knit: instance (Knit.GGatherTableIds ts, GHC.TypeLits.KnownSymbol table) => Knit.GGatherTableIds (Generics.Eot.Eot.Named table a, ts)
+ Knit: instance (Knit.GGatherTableIds ts, Knit.KnitRecord tables r, GHC.TypeLits.KnownSymbol table) => Knit.GGatherTableIds (Generics.Eot.Eot.Named table [r tables 'Knit.Unresolved], ts)
+ Knit: instance (Knit.GResolve u r, Knit.GResolve t s) => Knit.GResolve (Data.Either.Either u t) (Data.Either.Either r s)
+ Knit: instance (Knit.GResolve us rs, GHC.Base.Functor f) => Knit.GResolve (Generics.Eot.Eot.Named x (f (Knit.RecordId u)), us) (Generics.Eot.Eot.Named x (f u), rs)
+ Knit: instance (Knit.GResolveTables us ts, Knit.KnitRecord tables t) => Knit.GResolveTables (Generics.Eot.Eot.Named table [t tables 'Knit.Unresolved], us) (Generics.Eot.Eot.Named table [t tables 'Knit.Resolved], ts)
+ Knit: instance (Knit.KnitRecord tables r, Knit.GResolve us rs) => Knit.GResolve (Generics.Eot.Eot.Named x (r tables 'Knit.Unresolved), us) (Generics.Eot.Eot.Named x (r tables 'Knit.Resolved), rs)
+ Knit: instance (Knit.KnitRecord tables r, Knit.GResolve us rs, GHC.Base.Functor f) => Knit.GResolve (Generics.Eot.Eot.Named x (f (r tables 'Knit.Unresolved)), us) (Generics.Eot.Eot.Named x (f (r tables 'Knit.Resolved)), rs)
+ Knit: instance Control.DeepSeq.NFData Knit.ResolveError
+ Knit: instance Control.DeepSeq.NFData t => Control.DeepSeq.NFData (Knit.ForeignRecordId table field t)
+ Knit: instance Control.DeepSeq.NFData t => Control.DeepSeq.NFData (Knit.RecordId t)
+ Knit: instance GHC.Classes.Eq Knit.ResolveError
+ Knit: instance GHC.Classes.Eq t => GHC.Classes.Eq (Knit.ForeignRecordId table field t)
+ Knit: instance GHC.Classes.Eq t => GHC.Classes.Eq (Knit.RecordId t)
+ Knit: instance GHC.Classes.Ord Knit.ResolveError
+ Knit: instance GHC.Classes.Ord t => GHC.Classes.Ord (Knit.ForeignRecordId table field t)
+ Knit: instance GHC.Classes.Ord t => GHC.Classes.Ord (Knit.RecordId t)
+ Knit: instance GHC.Generics.Generic (Knit.ForeignRecordId table field t)
+ Knit: instance GHC.Generics.Generic (Knit.RecordId t)
+ Knit: instance GHC.Generics.Generic Knit.ResolveError
+ Knit: instance GHC.Num.Num t => GHC.Num.Num (Knit.ForeignRecordId table field t)
+ Knit: instance GHC.Show.Show Knit.Dynamic
+ Knit: instance GHC.Show.Show Knit.EId
+ Knit: instance GHC.Show.Show Knit.ResolveError
+ Knit: instance GHC.Show.Show t => GHC.Show.Show (Knit.ForeignRecordId table field t)
+ Knit: instance GHC.Show.Show t => GHC.Show.Show (Knit.RecordId t)
+ Knit: instance Knit.GGatherIds ()
+ Knit: instance Knit.GGatherIds GHC.Base.Void
+ Knit: instance Knit.GGatherIds us => Knit.GGatherIds (Generics.Eot.Eot.Named field u, us)
+ Knit: instance Knit.GGatherTableIds ()
+ Knit: instance Knit.GGatherTableIds GHC.Base.Void
+ Knit: instance Knit.GResolve () ()
+ Knit: instance Knit.GResolve GHC.Base.Void GHC.Base.Void
+ Knit: instance Knit.GResolve us rs => Knit.GResolve (Generics.Eot.Eot.Named x (Knit.RecordId u), us) (Generics.Eot.Eot.Named x u, rs)
+ Knit: instance Knit.GResolve us rs => Knit.GResolve (Generics.Eot.Eot.Named x u, us) (Generics.Eot.Eot.Named x u, rs)
+ Knit: instance Knit.GResolveTables () ()
+ Knit: instance Knit.GResolveTables u t => Knit.GResolveTables (Data.Either.Either u GHC.Base.Void) (Data.Either.Either t GHC.Base.Void)
+ Knit: instance Knit.GResolveTables us ts => Knit.GResolveTables (Generics.Eot.Eot.Named table a, us) (Generics.Eot.Eot.Named table a, ts)
+ Knit: instance forall k (tables :: k) (a :: k -> Knit.Mode -> *). GHC.Show.Show (Knit.Lazy tables a)
+ Knit: knit :: KnitTables t => t 'Unresolved -> Either ResolveError (t 'Resolved)
+ Knit: newtype Dynamic
+ Knit: newtype ForeignRecordId (table :: Symbol) (field :: Symbol) t
+ Knit: resolve :: (KnitRecord tables u, HasEot (u tables 'Unresolved)) => HasEot (u tables 'Resolved) => GResolve (Eot (u tables 'Unresolved)) (Eot (u tables 'Resolved)) => (TableName -> FieldName -> FieldValue -> Dynamic) -> u tables 'Unresolved -> u tables 'Resolved
+ Knit: resolveTables :: (KnitTables t, HasEot (t 'Unresolved)) => HasEot (t 'Resolved) => GResolveTables (Eot (t 'Unresolved)) (Eot (t 'Resolved)) => KnitTables t => (TableName -> FieldName -> FieldValue -> Dynamic) -> t 'Unresolved -> Either ResolveError (t 'Resolved)
+ Knit: toDynamic :: a -> Dynamic
+ Knit: type FieldName = String
+ Knit: type FieldValue = String
+ Knit: type TableName = String
+ Knit: type family Table (tables :: Mode -> *) (c :: Mode) table
+ Paths_knit: getBinDir :: IO FilePath
+ Paths_knit: getDataDir :: IO FilePath
+ Paths_knit: getDataFileName :: FilePath -> IO FilePath
+ Paths_knit: getDynLibDir :: IO FilePath
+ Paths_knit: getLibDir :: IO FilePath
+ Paths_knit: getLibexecDir :: IO FilePath
+ Paths_knit: getSysconfDir :: IO FilePath
+ Paths_knit: version :: Version

Files

knit.cabal view
@@ -7,7 +7,7 @@ -- hash: 9a018114683474c6cf3790641de1ab1452d949f9accab039ef8c9c01bc3dcf91  name:           knit-version:        0.3.0.0+version:        0.4.0.0 synopsis:       Ties the knot on data structures that reference each other by unique keys. description:    Please see the README on GitHub at <https://github.com/pkamenarsky/knit#readme> category:       Data Structures
src/Knit.hs view
@@ -4,32 +4,17 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PolyKinds #-}+{-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} -module Knit-  ( KnitRecord-  , KnitTables-  , Mode (..)--  , Table-  , Lazy (..)--  , Id-  , ForeignId--  , RecordId (..)-  , ForeignRecordId (..)--  , ResolveError (..)--  , knit-  )where+module Knit where  import           Control.DeepSeq (NFData) import qualified Control.Monad.ST as ST@@ -505,7 +490,12 @@         [ case M.lookup (table, field, show k) recordMap of             Nothing -> Just (table, field, show k)             Just _ -> Nothing-        | (_, [(_, _, fids)]) <- M.toList recordMap+        | (_, records) <- eids+        , record <- records+        , let fids =+                [ fid+                | fid@(EForeignId _ _ _) <- record+                ]         , EForeignId table field k <- fids         ]