I was unhappy with having to tinker with Refls when trying multiple matches on TypeRep, and I've ended up with these helpers:
-- introduces result in scopepatternIs::()=>a~~b=>Maybe(a:~~:b)patternIs=JustHRefl-- let's me pass expected type as type argumentas::forallab.Typeablea=>TypeRepb->Maybe(a:~~:b)as=eqTypeReptypeRep
which can be used as
casetypeOfxof(as@Int->Is)->_-- x ~~ Int in scope
Am I reinventing the wheel and there's already something similar or better?
PatternSynonyms are sort of interesting because the can both want and provide constraints - to make it possible to declare both situations, GHC recognizes two separate constraints in their signatures as corresponding options
I was unhappy with having to tinker with
Refl
s when trying multiple matches onTypeRep
, and I've ended up with these helpers:which can be used as
Am I reinventing the wheel and there's already something similar or better?
the
() =>
is some hack for pattern synonyms?PatternSynonyms
are sort of interesting because the can both want and provide constraints - to make it possible to declare both situations, GHC recognizes two separate constraints in their signatures as corresponding optionsSo
Is
wants()
(nothing) and providesa ~~ b
:big_smile:Once we have type applications in patterns, we'll be able to do
(I guess)
so does that mean you can't write
(a, b) => ...
asa => b => ...
instead? :oNot in signatures of patterns, but you can otherwise
It's a hack, but not a terrible one
I would snoop around singletons, to see if there is something like what you've defined