Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-16 Thread Sebastian Fischer
On Jul 15, 2009, at 2:30 PM, Hans Aberg wrote: If ++ could be pattern matched, what should have been the result of let (x++y)=[1,2,3] in (x,y)? It will branch. In terms of unification, you get a list of substitutions. f :: [a] - ([a],[a]) f (x ++ y) = (x,y) For an argument s, any pair

[Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Magicloud Magiclouds
Hi, I do not notice this before. fun ([0, 1] ++ xs) = .. in my code could not be compiled, parse error. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread minh thu
2009/7/15 Magicloud Magiclouds magicloud.magiclo...@gmail.com: Hi, I do not notice this before. fun ([0, 1] ++ xs) = .. in my code could not be compiled, parse error. ++ is a function; you can't pattern-match on that. Cheers, Thu ___ Haskell-Cafe

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread minh thu
2009/7/15 minh thu not...@gmail.com: 2009/7/15 Magicloud Magiclouds magicloud.magiclo...@gmail.com: Hi, I do not notice this before. fun ([0, 1] ++ xs) = .. in my code could not be compiled, parse error. ++ is a function; you can't pattern-match on that. But here you can match against

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Eugene Kirpichov
Technically, the reason is not that (++) is a function, but that it is not a constructor of the [] type. And, not only is it not a constructor, but it also *can't* be one, because the main characteristic of pattern matching in Haskell is that it is (contrary to Prolog's unification) unambiguous

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Hans Aberg
On 15 Jul 2009, at 12:25, Eugene Kirpichov wrote: If ++ could be pattern matched, what should have been the result of let (x++y)=[1,2,3] in (x,y)? It will branch. In terms of unification, you get a list of substitutions. Hans ___

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Luke Palmer
On Wed, Jul 15, 2009 at 3:08 AM, Hans Aberg hab...@math.su.se wrote: On 15 Jul 2009, at 12:25, Eugene Kirpichov wrote: If ++ could be pattern matched, what should have been the result of let (x++y)=[1,2,3] in (x,y)? It will branch. In terms of unification, you get a list of substitutions.

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Andrew Wagner
Err, technically, aren't functions and constructors mutually exclusive? So if something is a function, it's, by definition, not a constructor? On Wed, Jul 15, 2009 at 6:25 AM, Eugene Kirpichov ekirpic...@gmail.comwrote: Technically, the reason is not that (++) is a function, but that it is not

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Miguel Mitrofanov
No. Most constructors are functions, e.g. Just :: a - Maybe a - a function. On the other hand, Nothing :: Maybe a is a constructor, but not a function. Andrew Wagner wrote: Err, technically, aren't functions and constructors mutually exclusive? So if something is a function, it's, by

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Hans Aberg
On 15 Jul 2009, at 13:22, Luke Palmer wrote: If ++ could be pattern matched, what should have been the result of let (x++y)=[1,2,3] in (x,y)? It will branch. In terms of unification, you get a list of substitutions. f :: [a] - ([a],[a]) f (x ++ y) = (x,y) For an argument s, any pair (x,

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Felipe Lessa
On Wed, Jul 15, 2009 at 08:09:37AM -0400, Andrew Wagner wrote: Err, technically, aren't functions and constructors mutually exclusive? So if something is a function, it's, by definition, not a constructor? I guess what Eugene Kirpichov meant was that not being a function (and being a

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Richard O'Keefe
On Jul 15, 2009, at 9:59 PM, minh thu wrote: 2009/7/15 Magicloud Magiclouds magicloud.magiclo...@gmail.com: Hi, I do not notice this before. fun ([0, 1] ++ xs) = .. in my code could not be compiled, parse error. ++ is a function; you can't pattern-match on that. Doesn't matter, it's not

Re: [Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Richard O'Keefe
On Jul 15, 2009, at 9:57 PM, Magicloud Magiclouds wrote: Hi, I do not notice this before. fun ([0, 1] ++ xs) = .. in my code could not be compiled, parse error. I apologise to everyone for my previous message in this thread. There was a Haskell message in amongst some Erlang messages, and