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
I'm trying to get rid of the "value" :-> CoRec ElField '[("field1", type1), ("field2", type2)] column in favour of one column called "key" storing the labels and "value" storing the values. The first is quite easy:
type CollapsedFields = '["field1" :-> Int, "field2" :-> Int]
fld :: CoRec ElField CollapsedFields -> String
fld = foldCoRec func
where
func :: forall (a :: (Symbol, *)). a ∈ CollapsedFields => ElField a -> String
func x = case x of
Field _ -> getLabel x
but the latter is really difficult because GHC somehow needs to know that all fields are Integers—or know what to do if not. This therefore fails:
type CollapsedFields = '["field1" :-> Int, "field2" :-> Int]
fld :: CoRec ElField CollapsedFields -> Int
fld = foldCoRec func
where
func :: forall (a :: (Symbol, *)). a ∈ CollapsedFields => ElField a -> Int
func x = case x of
Field _ -> getField x
with
• Could not deduce: t ~ Int
from the context: (a ~ '(s, t), KnownSymbol s)
bound by a pattern with constructor:
Field :: forall (s :: Symbol) t.
KnownSymbol s =>
t -> ElField '(s, t),
in a case alternative
at xxxx
‘t’ is a rigid type variable bound by
a pattern with constructor:
Field :: forall (s :: Symbol) t.
KnownSymbol s =>
t -> ElField '(s, t),
in a case alternative
at xxxx
Expected type: ElField '(s, Int)
Actual type: ElField a
• In the first argument of ‘getField’, namely ‘x’
In the expression: getField x
In a case alternative: Field _ -> getField x (typecheck -Wdeferred-type-errors)
The match function that Vinyl provides seems not to work with ElField.
Any ideas how to do this?
The text was updated successfully, but these errors were encountered:
Hi all,
I'm trying to get rid of the
"value" :-> CoRec ElField '[("field1", type1), ("field2", type2)]
column in favour of one column called "key" storing the labels and "value" storing the values. The first is quite easy:but the latter is really difficult because GHC somehow needs to know that all fields are Integers—or know what to do if not. This therefore fails:
with
The
match
function that Vinyl provides seems not to work withElField
.Any ideas how to do this?
The text was updated successfully, but these errors were encountered: