[Haskell-cafe] A type in search of a name...

Brian Hulley brianh at metamilk.com
Tue Oct 10 10:51:56 EDT 2006


Hi,
You'll never believe it but I've been struggling last night and all of today 
to try and think up a name for the following type and I'm still nowhere near 
a solution:

    data ??? = VarId | VarSym | ConId | ConSym

this is part of a type to describe Haskell lexemes:

    data Token = TName !??? !ByteString.T | ...

Here are some of my attempts to fill in ??? and my reasons for rejecting 
them:

1) VarConIdSym - the problem is that it's too long and the first letter is 
'v' which could be confused with the letter 'V' in "VarId" or "VarSym"

2) Name - the problem is that this suggests the string itself rather than 
the VarId/VarSym/ConId/ConSym'ness of the token

3) NameType - I'm trying to avoid using the words "Type" "Kind" etc because 
I'll probably want to use these later for other things and in any case 
NameType suggests the type of a lexical name ie Token itself

4) Space - this can be confused with something to represent whitespace or 
the namespaces introduced by modules

5) Just using data Token = TVarId !BS.T | TVarSym !BS.T | ... -- explodes 
into too many different cases when you add tokens for qualified names and 
all their variations (since I'm also representing incomplete tokens like 
"Foo." and "Foo.where" (as a prefix of "Foo.whereas" etc since it can't 
stand by itself because "where" is a reserved word))

6) Using Bool as in data Token = TName !Bool !Bool !BS.T -- problem is that 
then I won't get any help from the typechecker if I accidentally confuse the 
order of Bools when matching etc. I could use the record syntax but then 
code can become very clunky to look at and it would still allow the Bools to 
get confused when they are passed about

Any ideas? I must say that trying to think up names for things is absolutely 
the most difficult task in programming imho. The problem is that once fixed 
down, a name gets used all over the place and becomes totally entrenched in 
the code and affects how one thinks about the code thereby influencing its 
whole future development in a very deep and pervasive way (think suffixes/ 
prefixes/ relationships with other concepts etc).

I would also be satisfied with just good names for the following types:

    data ???1 = Var | Con
    data ???2 = Id | Sym
    data ???3 = Op | Plain

(I just combined ???1 and ???2 in ??? to try and save some space in the 
representation but ideally they would be separate types if only there were a 
way to tell the compiler to represent each by 1 bit in a word at the machine 
level like C's struct {VarCon vc : 1; IdSym is : 1;})

Any suggestions welcome,
Thanks, Brian.
-- 
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 



More information about the Haskell-Cafe mailing list