Safe Haskell | None |
---|---|
Language | Haskell2010 |
Frames.Melt
Synopsis
- type family Elem (t :: a) (ts :: [a]) :: Bool where ...
- type family Or (a :: Bool) (b :: Bool) :: Bool where ...
- type family Not (a :: Bool) :: Bool where ...
- type family Disjoint (ss :: [a]) (ts :: [a]) :: Bool where ...
- type ElemOf (ts :: [k]) (r :: k) = RElem r ts (RIndex r ts)
- class RowToColumn (ts :: [k]) (rs :: [k]) where
- rowToColumnAux :: forall (f :: k -> Type). Proxy ts -> Rec f rs -> [CoRec f ts]
- rowToColumn :: forall {k} (ts :: [k]) (f :: k -> Type). RowToColumn ts ts => Rec f ts -> [CoRec f ts]
- meltAux :: forall (vs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]). (vs ⊆ ts, ss ⊆ ts, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => Record ts -> [Record (("value" :-> CoRec ElField vs) ': ss)]
- type family RDeleteAll (ss :: [a]) (ts :: [a]) :: [a] where ...
- meltRow' :: forall proxy (vs :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]). (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> Record ts -> [Record (("value" :-> CoRec ElField vs) ': ss)]
- retroSnoc :: forall (t :: (Symbol, Type)) (ts :: [(Symbol, Type)]). Record (t ': ts) -> Record (ts ++ '[t])
- meltRow :: forall (vs :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) proxy. (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> Record ts -> [Record (ss ++ '["value" :-> CoRec ElField vs])]
- class HasLength (ts :: [k]) where
- melt :: forall (vs :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) proxy. (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, HasLength vs, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> FrameRec ts -> FrameRec (ss ++ '["value" :-> CoRec ElField vs])
Documentation
class RowToColumn (ts :: [k]) (rs :: [k]) where Source #
Instances
RowToColumn (ts :: [k]) ('[] :: [k]) Source # | |
Defined in Frames.Melt | |
(r ∈ ts, RowToColumn ts rs) => RowToColumn (ts :: [a]) (r ': rs :: [a]) Source # | |
Defined in Frames.Melt |
rowToColumn :: forall {k} (ts :: [k]) (f :: k -> Type). RowToColumn ts ts => Rec f ts -> [CoRec f ts] Source #
Transform a record into a list of its fields, retaining proof that each field is part of the whole.
meltAux :: forall (vs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]). (vs ⊆ ts, ss ⊆ ts, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => Record ts -> [Record (("value" :-> CoRec ElField vs) ': ss)] Source #
type family RDeleteAll (ss :: [a]) (ts :: [a]) :: [a] where ... Source #
Equations
RDeleteAll ('[] :: [a]) (ts :: [a]) = ts | |
RDeleteAll (s ': ss :: [a]) (ts :: [a]) = RDeleteAll ss (RDelete s ts) |
meltRow' :: forall proxy (vs :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]). (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> Record ts -> [Record (("value" :-> CoRec ElField vs) ': ss)] Source #
This is melt
, but the variables are at the front of the record,
which reads a bit odd.
retroSnoc :: forall (t :: (Symbol, Type)) (ts :: [(Symbol, Type)]). Record (t ': ts) -> Record (ts ++ '[t]) Source #
Turn a cons into a snoc after the fact.
meltRow :: forall (vs :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) proxy. (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> Record ts -> [Record (ss ++ '["value" :-> CoRec ElField vs])] Source #
Like melt
in the reshape2
package for the R
language. It
stacks multiple columns into a single column over multiple
rows. Takes a specification of the id columns that remain
unchanged. The remaining columns will be stacked.
Suppose we have a record, r :: Record [Name,Age,Weight]
. If we
apply melt [pr1|Name|] r
, we get two values with type Record
[Name, "value" :-> CoRec Identity [Age,Weight]]
. The first will
contain Age
in the value
column, and the second will contain
Weight
in the value
column.
melt :: forall (vs :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) proxy. (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, HasLength vs, Disjoint ss ts ~ 'True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> FrameRec ts -> FrameRec (ss ++ '["value" :-> CoRec ElField vs]) Source #