Open cryogenian opened 7 years ago
Using Union
for this is kinda problematic because we need
Option
and may be missingseries
can have different configuration --> universal type parameters with Union
constraints won't work too --> only existential things like
newtype TextStyle = TextStyle (Exists Identity)
mkTextStyle :: forall r1 r2. Union r1 r2 TextStyleRow => Record r1 -> TextStyle
mkTextStyle = unsafeCoerce
runTextStyle :: forall res. TextStyle -> (forall r1 r2. Union r1 r2 TextStyleRow => Record r1 -> res) -> res
runTextStyle = unsafeCoerce runExists
newtype Series = Series (Exists Identity) mkLineSeries :: forall r1 r2. Union r1 r2 LineSeriesRow => Record r1 -> Series mkLineSeries = unsafeCoerce
mkBarSeries :: forall r1 r2. Union r1 r2 BarSeriesRow => Record r1 -> Series mkBarSeries = unsafeCoerce
runLineSeries :: forall res. Series -> (forall r1 r2. Union r1 r2 LineSeriesRow => Maybe (Record r1) -> res) -> res runLineSeries = ...
foldSeries :: forall res . Series -> -> (forall r1 r2. Union r1 r2 LineSeries => Record r1 -> res) -> (forall r1 r2. Union r1 r2 BarSeries => Record r1 -> res) -> ... -> res
The second one works but API isn't soo fancy
```purescript
mkChart
{ animationDuration: \i -> i * 100
, textStyle: mkTextStyle { fontSize: 14 }
, series: [ mkLineSeries lineSeries, mkBarSeries barSeries ]
}
Now with PS supporting polymorphic labels there is no need in phantom rows. We can use
RowCons
for this. E.g.This also removes need of returning
Foreign
fromgetOption
because we can know that field is set and can use https://github.com/purescript/purescript/blob/e4ff177017f1411ad4cbeade129cfe1bb52d6e99/examples/passing/PolyLabels.purs#L21