I want to be able to write something like:
reify (Proxy @True)) == True;
reify (Proxy @(Just 5)) == Just 5;
Is it possible by a blanket implementation? I got as far as
class Reify (a :: k) where
reify :: Proxy a -> k
And I have no idea how to write this except than writing every instance by hand: one instance for True, one instance for False, etc. I don't want to write it all by hand, and I don't want to use template haskell to do it for me. Can I have just one instance to do it?
Or maybe there exists some other approach? The use-case for me is to be able to write:
type DeriveHelper :: Settings -> Type -> Type
newtype DeriveHelper s a = DeriveHelper a
instance (Generic a, GMyClass (Rep a)) => MyClass (DeriveHelper s a) where
myMethod (DeriveHelper x) = genericMyMethod (reify (Proxy @s)) $ from x
-- and then
data FooBar ...
deriving MyClass via DeriveHelper SomeSettings FooBar
As for the libraries I've seen in the world that do this, they seem to all have small Settings which I believe is reified by hand.