alphanum in infix constructors (and possibly functions as well) - why not?
Hi all, The constructor names in Haskell need to obey one of the two following rules: - either starts with a capital letter and contains alphanumeric characters afterwards, (including _ I guess) - or starts with a colon (:) and only contains symbols afterwards The first one is used Prefix by default, and the second ose is used infix by default. What stops us from allowing alphanum characters appear in the Infix version (after the colon)? Can't it be relaxed to only start woth a colon? So I want to be able to say something like: data Expr = Expr :< Expr -- checks for LT betwen two Expr's | Expr :<2 Expr -- a different implementation of the same thing maybe | Expr :<veryfast Expr -- and the veryfast implementation of it (just a silly example I could think of now.) Best, Ozgur Akgun
Ozgur Akgun <ozgurakgun@gmail.com> writes:
Hi all,
The constructor names in Haskell need to obey one of the two following rules: - either starts with a capital letter and contains alphanumeric characters afterwards, (including _ I guess) - or starts with a colon (:) and only contains symbols afterwards
The first one is used Prefix by default, and the second ose is used infix by default.
What stops us from allowing alphanum characters appear in the Infix version (after the colon)? Can't it be relaxed to only start woth a colon?
The definition. I believe this is probably to make parsing of "foo:<bar" (using your example below) unambiguous, the same as how symbolic operators can't contain alphanumeric characters, etc.
So I want to be able to say something like:
data Expr = Expr :< Expr -- checks for LT betwen two Expr's | Expr :<2 Expr -- a different implementation of the same thing maybe | Expr :<veryfast Expr -- and the veryfast implementation of it
How does a data structure have a faster implementation? >_> -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com
On 4 June 2010 12:33, Ivan Lazar Miljenovic <ivan.miljenovic@gmail.com>wrote:
Ozgur Akgun <ozgurakgun@gmail.com> writes: [...]
What stops us from allowing alphanum characters appear in the Infix
version
(after the colon)? Can't it be relaxed to only start woth a colon?
The definition. I believe this is probably to make parsing of "foo:<bar" (using your example below) unambiguous, the same as how symbolic operators can't contain alphanumeric characters, etc.
I see. Then people would need to put spaces between those things, right? What a horrible consequence!
So I want to be able to say something like:
data Expr = Expr :< Expr -- checks for LT betwen two Expr's | Expr :<2 Expr -- a different implementation of the same thing maybe | Expr :<veryfast Expr -- and the veryfast implementation of it
How does a data structure have a faster implementation? >_>
Well it might indicate to use a different function while evaluating the expression. Still not a good example, I know. Best, Ozgur
Ozgur Akgun <ozgurakgun@gmail.com> writes:
Then people would need to put spaces between those things, right? What a horrible consequence!
I like to think that Haskell is a language where aesthetics matter. So, in my opinion this is indeed a horrible consequence. I find mixing of symbols and letters in identfiers to be in itself aesthetically inferior, and there's already more than enough whitespace-dependent parsing warts in Haskell. -k -- If I haven't seen further, it is by standing in the footprints of giants
OK I back up. I justed wanted it to happen for a moment :) You're right, ambiguity in parsing and a lot of whitespace-dependency are things to avoid. Best, On 4 June 2010 14:25, Ketil Malde <ketil@malde.org> wrote:
Ozgur Akgun <ozgurakgun@gmail.com> writes:
Then people would need to put spaces between those things, right? What a horrible consequence!
I like to think that Haskell is a language where aesthetics matter. So, in my opinion this is indeed a horrible consequence.
I find mixing of symbols and letters in identfiers to be in itself aesthetically inferior, and there's already more than enough whitespace-dependent parsing warts in Haskell.
-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
-- Ozgur Akgun
participants (3)
-
Ivan Lazar Miljenovic -
Ketil Malde -
Ozgur Akgun