[Haskell-cafe] Exposing a GADT-provided dictionary
Kosyrev Serge
serge.kosyrev at iohk.io
Tue Oct 17 12:25:35 UTC 2017
On 10/16/2017 02:56 PM, Li-yao Xia wrote:
>
> Would refactoring the type like this work for you?
>
>> data GADT a where
>> G :: HasDict a => Tag -> a -> GADT a
>>
>> data Tag = Tag1 | ... | Tagn
>>
>> withGADTDict :: ...
>> withGADTDict body x = x & case x of
>> G _ _ -> body
Li, thank you for your reply!
I've needed the GADT clauses for their different structure,
so I've had to add a layer of structural indirection to a plain ADT.
But the spirit of your suggestion (to reduce the dict-providing GADT to
a single clause) was all the same.
--
с уважениeм / respectfully,
Kosyrev Serge
PGP Key ID: 3F62F118E38BED6D
--
“Most deadly errors arise from obsolete assumptions.”
-- Frank Herbert, Children of Dune
More information about the Haskell-Cafe
mailing list