
I'm afraid I'd got into a muddle, and all of this can be ignored.
In general, top-level and associated type instances get the same
syntactic treatment in module exports, and the problem I had in the
first place was due to another mistake.
Ben
On Mon, Dec 22, 2008 at 4:26 PM, Ben Horsfall
Hi Wolfgang,
On Mon, Dec 22, 2008 at 12:23 PM, Wolfgang Jeltsch
wrote: Am Montag, 15. Dezember 2008 02:17 schrieb Ben Horsfall:
I have a type family
class Lang term where data Token term :: *
with
instance Lang Term where newtype Token Term = T String
I can't work out how to export the type constructor T from the module, unless I make no explict exports from the module at all.
Ben
Hello Ben,
try
Lang (type Token)
in the export list.
Best wishes, Wolfgang
That exports just the name of the associated type from the type class, as far as I can see, and syntax like "Lang (type Token (..))" is not allowed. That would improperly mix the classes and instances, for one thing. But perhaps something similar ought to be permited for associated type instances, as in my example. Something like:
module Term (Term (Token Term (T)))
is what I'd have in mind.
In the meantime, I can step around the issue by making Token a top-level type familiy alongside the Lang class:
data family Token term :: *
with instance:
newtype instance Token Term = T String
alongside the instance Lang Term, allowing me to make the module exports I wanted in the usual style:
module Term (Term (..), Token (T))
But this is a bit curious. The module might have contained more than one instance of Token, and this syntax mentions the name of the type family and a constructor for an instance of it, but not the type instance Token Term itself (although a constructor will always uniquely determine a type instance).
This reminds me to mention that I've had the class and instance declarations in separate modules all along. Also, I'm using GHC 6.10.1.
Ben