Implement Data.Reflectable#289
Conversation
JordanMartinez
left a comment
There was a problem hiding this comment.
Could you add tests for both the Reflectable and Reifiable type classes?
|
Should I copy-paste the tests from the compiler? https://github.com/purescript/purescript/blob/1d5c618054bc0c452128e8758dc01b758a3a6f39/tests/purs/passing/SolvingReflectable.purs I think testing |
Co-authored-by: Thomas Honeyman <hello@thomashoneyman.com>
I think adding it here forces other backends to also implement the tests, which aren't being tested in the compiler. We'd also probably want something more granular. testReflection :: AlmostEff
testReflection = do
assert "Symbol reflection" $ reflectType (Proxy :: Proxy "foo") == "foo"
assert "Int reflection - 1" $ reflectType (Proxy :: Proxy 1) == 1
assert "Int reflection - 0" $ reflectType (Proxy :: Proxy 0) == 0
assert "Int reflection - (-1)" $ reflectType (Proxy :: Proxy (-1)) == (-1)
assert "Boolean - True reflection" $ reflectType (Proxy :: Proxy PB.True) == true
assert "Boolean - False reflection" $ reflectType (Proxy :: Proxy PB.False) == false
assert "Ordering - LT reflection" $ reflectType (Proxy :: Proxy PO.LT) == LT
assert "Ordering - EQ reflection" $ reflectType (Proxy :: Proxy PO.EQ) == EQ
assert "Ordering - GT reflection" $ reflectType (Proxy :: Proxy PO.GT) == GTSimilarly for the |
thomashoneyman
left a comment
There was a problem hiding this comment.
👍 thanks, @purefunctor!
Closes #286. Adds a
Data.Reflectablemodule which is where the compiler looks at for the automatically-solvedReflectabletype class.Checklist: