Trying to get the basic example from the README of heterogeneous
working. Any pointers much appreciated.
data ShowProps = ShowProps
instance showProps ::
(Show a, IsSymbol sym) =>
FoldingWithIndex ShowProps (SProxy sym) String a String where
foldingWithIndex ShowProps prop str a =
pre <> reflectSymbol prop <> ": " <> show a
where
pre | str == "" = ""
| otherwise = str <> ", "
showRecord :: forall r.
HFoldlWithIndex ShowProps String { | r } String =>
{ | r } ->
String
showRecord r =
"{ " <> hfoldlWithIndex ShowProps "" r <> " }"
showRecord { a: "foo" , b: 42 , c: false }
However:
No type class instance was found for
Heterogeneous.Folding.FoldingWithIndex ShowProps
(Proxy "bar")
String
Int
t2
while solving type class constraint
Heterogeneous.Folding.FoldlRecord ShowProps
String
t1
( bar :: Int
, baz :: Boolean
, foo :: String
)
String
while applying a function showRecord
of type HFoldlWithIndex ShowProps String (Record t0) String => Record t0 -> String
to argument { foo: "foo"
, bar: 42
, baz: false
}
while inferring the type of showRecord { foo: "foo"
, bar: 42
, baz: false
}