You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The motivation here is that using SProxy _ is a bit more cumbersome than seems necessary. Record syntax is a bit more lightweight to toss around.
It seems like fromRecord could be implemented like:
moduleData.VariantwhereclassFromRecord (list :: Prim.RowList.RowList) recordvariantwherefromRecord'::forallproxy. proxylist->Recordrecord->VariantvariantinstancefromRecordSingleton ::
( Data.Symbol.IsSymbol label
, Prim.Row.Cons label value () record
, Prim.Row.Cons label value variant' variant
) =>
FromRecord (Prim.RowList.Cons label value Prim.RowList.Nil) record variant
where
fromRecord' _ record = inj label (Record.get label record)
wherelabel::Data.Symbol.SProxylabel
label = Data.Symbol.SProxyfromRecord::foralllistrecordvariant.
Prim.RowList.RowToListrecordlist=>FromRecordlistrecordvariant=>Recordrecord->Variantvariant
fromRecord = fromRecord' (Type.Data.RowList.RLProxy::_list)
Might want some fundeps, dunno. If we want to be helpful, adding some custom error messages for using the wrong size record should be possible as well:
else instancefromRecordMultiple ::
( Prim.TypeError.Fail?someErrorMessageAboutMultipleFieldsInTheRecord
) =>
FromRecord (Prim.RowList.Cons label value list) record variant
where
fromRecord' proxy record = fromRecord' proxy record
else instancefromRecordEmpty ::
( Prim.TypeError.Fail?someErrorMessageAboutTheEmptyRecord
) =>
FromRecordPrim.RowList.Nil record variant
where
fromRecord' proxy record = fromRecord' proxy record
The text was updated successfully, but these errors were encountered:
Is there any interest in adding something that allows constructing a variant with a singleton record?
The motivation here is that using
SProxy _
is a bit more cumbersome than seems necessary. Record syntax is a bit more lightweight to toss around.It seems like
fromRecord
could be implemented like:Might want some fundeps, dunno. If we want to be helpful, adding some custom error messages for using the wrong size record should be possible as well:
The text was updated successfully, but these errors were encountered: