[Haskell-cafe] typeclass constraints?
will.yager at gmail.com
Sat Nov 5 19:43:22 UTC 2016
You probably want
data Test = forall a . Show a => Test String a
Under the hood, this works by storing the vtable for the "Show" typeclass
for whatever object you're putting in the Test. You could explicitly unpack
data TestY = forall a . Test String a (a -> String)
On Sat, Nov 5, 2016 at 2:09 PM, Gregory Guthrie <guthrie at mum.edu> wrote:
> data (Show a) => ATest = Test (String, a)
> but that also fails, although it does give the right idea; all tests have
> a common structure, with a second value in the Show typeclass.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe