Re: [Haskell-cafe] Lisp like symbols in haskell
* jean-christophe mincke: > Has there already been attempts to introduce lisp like symbols in haskell? Do you mean something like Objective Caml's polymorphic variants? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
wrote: > 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-StableName.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
Luke Palmer writes: > 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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
On Tue, Dec 8, 2009 at 1:48 AM, Michael Vanier 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. 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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
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 > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
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. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
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
Re: [Haskell-cafe] Lisp like symbols in haskell
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
Re: [Haskell-cafe] Lisp like symbols in haskell
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-haskell/index.htm 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 > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lisp like symbols in haskell
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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe