
Hello, Has there already been attempts to introduce lisp like symbols in haskell? Thank you Regards J-C

On Tue, 2009-12-08 at 09:21 +0100, jean-christophe mincke wrote:
Hello,
Has there already been attempts to introduce lisp like symbols in haskell?
I'm not sure if this answers your question, but there is an attempt to mix Lisp syntax with Haskell semantics, called Liskell. Description: http://clemens.endorphin.org/ILC07-Liskell-draft.pdf Latest news: http://blog.clemens.endorphin.org/2009/01/liskell-standalone.html Have fun, -- Ariel J. Birnbaum

Hi Jean-Christophe
There is no mention in the 'History of Haskell' which is probably the
most authoritative published reference
http://research.microsoft.com/en-us/um/people/simonpj/papers/history-of-hask...
If someone wanted to introduce symbols, they would presumably have to
propose an extension to the type system to handle them - don't symbols
in Lisp and Scheme rely on lists being dynamically typed?
Best wishes
Stephen
2009/12/8 jean-christophe mincke
Hello,
Has there already been attempts to introduce lisp like symbols in haskell?
Thank you
Regards
J-C
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

jean-christophe mincke wrote:
Hello,
Has there already been attempts to introduce lisp like symbols in haskell?
Thank you
Regards
J-C
J-C, Do you mean symbols as in "interned strings with an O(1) string comparison method"? I would love to have those, but I don't see an easy way to get it without being in the IO or ST monad. Mike

Aren't symbols made redundant by algebraic data types?
On Tue, Dec 8, 2009 at 4:48 PM, Michael Vanier
jean-christophe mincke wrote:
Hello,
Has there already been attempts to introduce lisp like symbols in haskell?
Thank you
Regards
J-C
J-C,
Do you mean symbols as in "interned strings with an O(1) string comparison method"? I would love to have those, but I don't see an easy way to get it without being in the IO or ST monad.
Mike
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Probably in the same way integers are made redundant :
data Integer = 0 | 1 | 2 | ....
Cheers,
Thu
2009/12/8 Lyndon Maydwell
Aren't symbols made redundant by algebraic data types?
On Tue, Dec 8, 2009 at 4:48 PM, Michael Vanier
wrote: jean-christophe mincke wrote:
Hello,
Has there already been attempts to introduce lisp like symbols in haskell?
Thank you
Regards
J-C
J-C,
Do you mean symbols as in "interned strings with an O(1) string comparison method"? I would love to have those, but I don't see an easy way to get it without being in the IO or ST monad.
Mike
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I think stable names can be used where symbols are used in scheme. I think there are better alternatives for different use cases in haskell. For example, symbols are often used to tag values - haskell has pattern matching on constructors.

Vladimir Zlatanov wrote:
I think stable names can be used where symbols are used in scheme. I think there are better alternatives for different use cases in haskell.
For example, symbols are often used to tag values - haskell has pattern matching on constructors.
Here is a link: http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-Stable... Cheers Ben

Hello Michael, Tuesday, December 8, 2009, 11:48:09 AM, you wrote:
Do you mean symbols as in "interned strings with an O(1) string comparison method"? I would love to have those, but I don't see an easy way to get it without being in the IO or ST monad.
you could intern IO usage with unsafePerformIO. it's implemented in GHC sources, afair it's FastString type or so -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Tue, Dec 8, 2009 at 1:48 AM, Michael Vanier
Do you mean symbols as in "interned strings with an O(1) string comparison method"? I would love to have those, but I don't see an easy way to get it without being in the IO or ST monad.
data Sym = Sym String Hash fromString :: String -> Sym fromString s = Sym s (hash s) instance Eq Sym where Sym _ h == Sym _ h' = h == h' Much as I am uncomfortable with hash-based equality. 1/2^256, despite being very small, is not zero. It is begging for a mysterious failure someday. Luke

Luke Palmer
data Sym = Sym String Hash
fromString :: String -> Sym fromString s = Sym s (hash s)
instance Eq Sym where Sym _ h == Sym _ h' = h == h'
Much as I am uncomfortable with hash-based equality. 1/2^256, despite being very small, is not zero. It is begging for a mysterious failure someday.
How about: instance Eq Sym where Sym s h == Sym s' h' = h == h' && s == s' So, very fast if the hashes fail to match, only marginally slower than just the string comparison if they are equal. -k -- If I haven't seen further, it is by standing in the footprints of giants

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

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.
Well for such use-case you could use either stable names, or recode them into a state monad- you will get either a global i.e. lisp like unique symbols, or their equivalent within a state context. Or some variation of the code posted previously in this thread. http://www.haskell.org/ghc/docs/6.10.4/html/libraries/base/System-Mem-Stable...
participants (12)
-
Ariel J. Birnbaum
-
Ben Franksen
-
Bulat Ziganshin
-
Florian Weimer
-
jean-christophe mincke
-
Ketil Malde
-
Luke Palmer
-
Lyndon Maydwell
-
Michael Vanier
-
minh thu
-
Stephen Tetley
-
Vladimir Zlatanov