
8 Mar
2015
8 Mar
'15
12:11 p.m.
Given a class Foo:
class Foo f where> bar :: f -> Bool> baz :: f -> Char -> Int does the record type Foo' data Foo' = Foo' {> bar' :: Bool,> baz' :: Char -> Int> }> > instance Foo Foo' where> bar = bar'> baz = baz' where the fields of the record Foo' are just implementations of the functions of Foo have any special name? In some sense it's a canonical instance of Foo; we could trivially write a universal toFoo' :: Foo f => f -> Foo' function. I ran across this pattern and wondered whether it was useful enough to have received a name. It vaguely resembles a typeclass dictionary or a vtable in an OOP language. --Eric