Last active
October 15, 2018 09:55
-
-
Save dariooddenino/ccf96a566cb731cde30a31231deb321e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data ShowProps = ShowProps (forall sym. IsSymbol sym => SProxy sym -> String) | |
instance showProps :: | |
(Show a, IsSymbol sym) => | |
FoldingWithIndex (ShowProps) (SProxy sym) String a String where | |
foldingWithIndex (ShowProps fn) prop str a = | |
pre <> fn prop <> ": " <> show a | |
where | |
pre | str == "" = "" | |
| otherwise = str <> ", " | |
showRecord :: forall r sym. | |
IsSymbol sym => | |
HFoldlWithIndex (ShowProps) String { | r } String => | |
(forall sym2. IsSymbol sym2 => SProxy sym2 -> String) -> | |
{ | r } -> | |
String | |
showRecord fn r = | |
"{ " <> hfoldlWithIndex (ShowProps fn) "" r <> " }" | |
bu :: | |
forall sym a. | |
FoldingWithIndex ShowProps (SProxy sym) String a String => | |
String | |
bu = showRecord reflectSymbol' { a: "foo", b: 1 } | |
where | |
reflectSymbol' :: forall sym2. IsSymbol sym2 => SProxy sym2 -> String | |
reflectSymbol' = reflectSymbol | |
-- No type class instance was found for IsSymbol t0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment