| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
DataFrame.Typed.Schema
Synopsis
- type family Lookup (name :: Symbol) (cols :: [Type]) where ...
- type family HasName (name :: Symbol) (cols :: [Type]) :: Bool where ...
- type family RemoveColumn (name :: Symbol) (cols :: [Type]) :: [Type] where ...
- type family Impute (name :: Symbol) (cols :: [Type]) :: [Type] where ...
- type family SubsetSchema (names :: [Symbol]) (cols :: [Type]) :: [Type] where ...
- type family ExcludeSchema (names :: [Symbol]) (cols :: [Type]) :: [Type] where ...
- type family RenameInSchema (old :: Symbol) (new :: Symbol) (cols :: [Type]) :: [Type] where ...
- type family RenameManyInSchema (pairs :: [(Symbol, Symbol)]) (cols :: [Type]) :: [Type] where ...
- type family Append (xs :: [k]) (ys :: [k]) :: [k] where ...
- type family Snoc (xs :: [k]) (x :: k) :: [k] where ...
- type family Reverse (xs :: [Type]) :: [Type] where ...
- type family ColumnNames (cols :: [Type]) :: [Symbol] where ...
- type family AssertAbsent (name :: Symbol) (cols :: [Type]) where ...
- type family AssertPresent (name :: Symbol) (cols :: [Type]) where ...
- type family AssertAllPresent (name :: [Symbol]) (cols :: [Type]) where ...
- type family IsElem (x :: Symbol) (xs :: [Symbol]) :: Bool where ...
- type family StripAllMaybe (cols :: [Type]) :: [Type] where ...
- type family StripMaybeAt (name :: Symbol) (cols :: [Type]) :: [Type] where ...
- type family SharedNames (left :: [Type]) (right :: [Type]) :: [Symbol] where ...
- type family UniqueLeft (left :: [Type]) (rightNames :: [Symbol]) :: [Type] where ...
- type family InnerJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ...
- type family LeftJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ...
- type family RightJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ...
- type family FullOuterJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ...
- type family WrapMaybe (cols :: [Type]) :: [Type] where ...
- type family WrapMaybeColumns (names :: [Symbol]) (cols :: [Type]) :: [Type] where ...
- type family CollidingColumns (left :: [Type]) (right :: [Type]) (keys :: [Symbol]) :: [Type] where ...
- type family GroupKeyColumns (keys :: [Symbol]) (cols :: [Type]) :: [Type] where ...
- class KnownSchema (cols :: [Type]) where
- schemaEvidence :: [(Text, SomeTypeRep)]
- class AllKnownSymbol (names :: [Symbol]) where
- symbolVals :: [Text]
Type families for schema manipulation
type family Lookup (name :: Symbol) (cols :: [Type]) where ... Source #
Look up the element type of a column by name.
type family HasName (name :: Symbol) (cols :: [Type]) :: Bool where ... Source #
Check whether a column name exists in a schema (type-level Bool).
type family RemoveColumn (name :: Symbol) (cols :: [Type]) :: [Type] where ... Source #
Remove a column by name from a schema.
Equations
| RemoveColumn name (Column name _1 ': rest) = rest | |
| RemoveColumn name (col ': rest) = col ': RemoveColumn name rest | |
| RemoveColumn name ('[] :: [Type]) = '[] :: [Type] |
type family Impute (name :: Symbol) (cols :: [Type]) :: [Type] where ... Source #
Unwrap a Maybe from a type after we impute values.
Equations
| Impute name (Column name (Maybe a) ': rest) = Column name a ': rest | |
| Impute name (Column name _1 ': rest) = TypeError (('Text "Column '" ':<>: 'Text name) ':<>: 'Text "' is not of kind Maybe *") :: [Type] | |
| Impute name (col ': rest) = col ': Impute name rest | |
| Impute name ('[] :: [Type]) = '[] :: [Type] |
type family SubsetSchema (names :: [Symbol]) (cols :: [Type]) :: [Type] where ... Source #
Select a subset of columns by a list of names.
Equations
| SubsetSchema ('[] :: [Symbol]) cols = '[] :: [Type] | |
| SubsetSchema (n ': ns) cols = Column n (Lookup n cols) ': SubsetSchema ns cols |
type family ExcludeSchema (names :: [Symbol]) (cols :: [Type]) :: [Type] where ... Source #
Exclude columns by a list of names.
Equations
| ExcludeSchema names ('[] :: [Type]) = '[] :: [Type] | |
| ExcludeSchema names (Column n a ': rest) = If (IsElem n names) (ExcludeSchema names rest) (Column n a ': ExcludeSchema names rest) |
type family RenameInSchema (old :: Symbol) (new :: Symbol) (cols :: [Type]) :: [Type] where ... Source #
Rename a column in the schema.
Equations
| RenameInSchema old new (Column old a ': rest) = Column new a ': rest | |
| RenameInSchema old new (col ': rest) = col ': RenameInSchema old new rest | |
| RenameInSchema old new ('[] :: [Type]) = TypeError (('Text "Cannot rename: column '" ':<>: 'Text old) ':<>: 'Text "' not found") :: [Type] |
type family RenameManyInSchema (pairs :: [(Symbol, Symbol)]) (cols :: [Type]) :: [Type] where ... Source #
Rename multiple columns.
Equations
| RenameManyInSchema ('[] :: [(Symbol, Symbol)]) cols = cols | |
| RenameManyInSchema ('(old, new) ': rest) cols = RenameManyInSchema rest (RenameInSchema old new cols) |
type family ColumnNames (cols :: [Type]) :: [Symbol] where ... Source #
Extract column names as a type-level list of Symbols.
Equations
| ColumnNames ('[] :: [Type]) = '[] :: [Symbol] | |
| ColumnNames (Column n _1 ': rest) = n ': ColumnNames rest |
type family AssertAbsent (name :: Symbol) (cols :: [Type]) where ... Source #
Assert that a column name is absent from the schema (for derive/insert).
Equations
| AssertAbsent name cols = AssertAbsentHelper name (HasName name cols) cols |
type family AssertPresent (name :: Symbol) (cols :: [Type]) where ... Source #
Assert that a column name is present in the schema.
Equations
| AssertPresent name cols = AssertPresentHelper name (HasName name cols) cols |
type family AssertAllPresent (name :: [Symbol]) (cols :: [Type]) where ... Source #
Assert that a column name is present in the schema.
Equations
| AssertAllPresent (name ': rest) cols = If (HasName name cols) (AssertAllPresent rest cols) (TypeError (('Text "Column '" ':<>: 'Text name) ':<>: 'Text "' not found in schema") :: Constraint) | |
| AssertAllPresent ('[] :: [Symbol]) cols = () |
type family IsElem (x :: Symbol) (xs :: [Symbol]) :: Bool where ... Source #
Type-level elem for Symbols
Maybe-stripping families
type family StripAllMaybe (cols :: [Type]) :: [Type] where ... Source #
Strip Maybe from all columns. Used by filterAllJust.
Column "x" (Maybe Double) becomes Column "x" Double.
Column "y" Int stays Column "y" Int.
Equations
| StripAllMaybe ('[] :: [Type]) = '[] :: [Type] | |
| StripAllMaybe (Column n (Maybe a) ': rest) = Column n a ': StripAllMaybe rest | |
| StripAllMaybe (Column n a ': rest) = Column n a ': StripAllMaybe rest |
type family StripMaybeAt (name :: Symbol) (cols :: [Type]) :: [Type] where ... Source #
Strip Maybe from a single named column. Used by filterJust.
StripMaybeAt "x" '[Column "x" (Maybe Double), Column "y" Int]
= '[Column "x" Double, Column "y" Int]
Equations
| StripMaybeAt name (Column name (Maybe a) ': rest) = Column name a ': rest | |
| StripMaybeAt name (Column name a ': rest) = Column name a ': rest | |
| StripMaybeAt name (col ': rest) = col ': StripMaybeAt name rest | |
| StripMaybeAt name ('[] :: [Type]) = TypeError (('Text "Column '" ':<>: 'Text name) ':<>: 'Text "' not found in schema") :: [Type] |
Join schema families
type family SharedNames (left :: [Type]) (right :: [Type]) :: [Symbol] where ... Source #
Extract column names that appear in both schemas.
Equations
| SharedNames ('[] :: [Type]) right = '[] :: [Symbol] | |
| SharedNames (Column n _1 ': rest) right = If (HasName n right) (n ': SharedNames rest right) (SharedNames rest right) |
type family UniqueLeft (left :: [Type]) (rightNames :: [Symbol]) :: [Type] where ... Source #
Columns from left whose names do NOT appear in right.
Equations
| UniqueLeft ('[] :: [Type]) _1 = '[] :: [Type] | |
| UniqueLeft (Column n a ': rest) rn = If (IsElem n rn) (UniqueLeft rest rn) (Column n a ': UniqueLeft rest rn) |
type family InnerJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ... Source #
Inner join result schema.
Equations
| InnerJoinSchema keys left right = Append (SubsetSchema keys left) (Append (UniqueLeft left (Append keys (ColumnNames right))) (Append (UniqueLeft right (Append keys (ColumnNames left))) (CollidingColumns left right keys))) |
type family LeftJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ... Source #
Left join result schema.
Equations
| LeftJoinSchema keys left right = Append (SubsetSchema keys left) (Append (UniqueLeft left (Append keys (ColumnNames right))) (Append (WrapMaybe (UniqueLeft right (Append keys (ColumnNames left)))) (CollidingColumns left right keys))) |
type family RightJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ... Source #
Right join result schema.
Equations
| RightJoinSchema keys left right = Append (SubsetSchema keys right) (Append (WrapMaybe (UniqueLeft left (Append keys (ColumnNames right)))) (Append (UniqueLeft right (Append keys (ColumnNames left))) (CollidingColumns left right keys))) |
type family FullOuterJoinSchema (keys :: [Symbol]) (left :: [Type]) (right :: [Type]) :: [Type] where ... Source #
Full outer join result schema.
Equations
| FullOuterJoinSchema keys left right = Append (WrapMaybe (SubsetSchema keys left)) (Append (WrapMaybe (UniqueLeft left (Append keys (ColumnNames right)))) (Append (WrapMaybe (UniqueLeft right (Append keys (ColumnNames left)))) (CollidingColumns left right keys))) |
type family WrapMaybeColumns (names :: [Symbol]) (cols :: [Type]) :: [Type] where ... Source #
Wrap selected columns in Maybe by name list.
Equations
| WrapMaybeColumns names ('[] :: [Type]) = '[] :: [Type] | |
| WrapMaybeColumns names (Column n a ': rest) = If (IsElem n names) (Column n (Maybe a) ': WrapMaybeColumns names rest) (Column n a ': WrapMaybeColumns names rest) |
type family CollidingColumns (left :: [Type]) (right :: [Type]) (keys :: [Symbol]) :: [Type] where ... Source #
Columns in left whose names collide with right (excluding keys).
Equations
| CollidingColumns ('[] :: [Type]) _1 _2 = '[] :: [Type] | |
| CollidingColumns (Column n a ': rest) right keys = If (IsElem n keys) (CollidingColumns rest right keys) (If (HasName n right) (Column n (These a (Lookup n right)) ': CollidingColumns rest right keys) (CollidingColumns rest right keys)) |
GroupBy helpers
type family GroupKeyColumns (keys :: [Symbol]) (cols :: [Type]) :: [Type] where ... Source #
Extract Column entries from a schema whose names appear in keys.
Equations
| GroupKeyColumns keys ('[] :: [Type]) = '[] :: [Type] | |
| GroupKeyColumns keys (Column n a ': rest) = If (IsElem n keys) (Column n a ': GroupKeyColumns keys rest) (GroupKeyColumns keys rest) |
KnownSchema class
class KnownSchema (cols :: [Type]) where Source #
Provides runtime evidence of a schema: a list of (name, TypeRep) pairs.
Methods
schemaEvidence :: [(Text, SomeTypeRep)] Source #
Instances
| KnownSchema ('[] :: [Type]) Source # | |
Defined in DataFrame.Typed.Schema Methods schemaEvidence :: [(Text, SomeTypeRep)] Source # | |
| (KnownSymbol name, Typeable a, Columnable a, KnownSchema rest) => KnownSchema (Column name a ': rest) Source # | |
Defined in DataFrame.Typed.Schema Methods schemaEvidence :: [(Text, SomeTypeRep)] Source # | |
Helpers
class AllKnownSymbol (names :: [Symbol]) where Source #
A class that provides a list of Text values for a type-level list of Symbols.
Methods
symbolVals :: [Text] Source #
Instances
| AllKnownSymbol ('[] :: [Symbol]) Source # | |
Defined in DataFrame.Typed.Schema Methods symbolVals :: [Text] Source # | |
| (KnownSymbol n, AllKnownSymbol ns) => AllKnownSymbol (n ': ns) Source # | |
Defined in DataFrame.Typed.Schema Methods symbolVals :: [Text] Source # | |