[Haskell-cafe] Lisp like symbols in haskell

jean-christophe mincke jeanchristophe.mincke at gmail.com
Tue Dec 8 05:28:02 EST 2009


I think lisp like symbols could be quite useful in the context of embedded
DSL to create ... well... symbols that can be interpreted as variables in
that DSL.

I can imagine something such as a small relational DSL  i.e

Without symbols we have several alternatives:

1. Symbols are written as strings (and possibly automatically lifted to
Symbol string if necessary, It is possible for nums I do not know for
strings). Moreover the system should be able to tell the difference between
a string representing a symbol and a string representing a string value

"Table_A" 'where' "Att_Name" = "Smith" 'and' "Att_Age" > 10


2. Using algebraic data type: the syntax looks better but the data type must
be declared before. In this case we must know in advance all the attributes
and table names (including all the names used in 'rename' relational
opération - the 'as' in sql).

Table_A 'where' Att_Name = "Smith" 'and' Att_Age > 10

3 If we had symbols. Note lisp like symbols might well be values of some
predefined type "Symbol". Just like 2,3, 56 are values of the predefined
type Integer.

Table_A 'where' Att_Name = "Smith" 'and' Att_Age > 10

Here the problem is that the compiler should be able to tell the difference
between a symbol and an undefined variable. Lisp solves it by prefixing the
symbol with a little '.  Smalltalk prefixes it with #.

So with unambiguous symbols:

'Table_A 'where'  'Att_Name = "Smith" 'and'  'Att_Age > 10  or
#Table_A 'where'  #Att_Name = "Smith" 'and'  #Att_Age > 10


Regards


J-C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091208/65e2180c/attachment.html


More information about the Haskell-Cafe mailing list