[Haskell-cafe] Data.Map.Map Pattern Matching

2009-05-13 Thread Nico Rolle
Hi

I tried this but it diddn't work in ghci:

import qualified Data.Map as Map

test :: Map.Map [Int] [[Int]] - Bool
test (fromList[((i:is), (j:js))]) = [i] == j

i get the : Parse error in pattern
Failed. error.

regards
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Map.Map Pattern Matching

2009-05-13 Thread Max Rabkin
On Wed, May 13, 2009 at 7:06 PM, Nico Rolle nro...@web.de wrote:
 Hi

 I tried this but it diddn't work in ghci:

 import qualified Data.Map as Map

 test :: Map.Map [Int] [[Int]] - Bool
 test (fromList[((i:is), (j:js))]) = [i] == j

 i get the : Parse error in pattern
 Failed. error.

fromList is an ordinary function. Pattern-matching only works on
constructors (unless you use view patterns [see
http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns]).

--Max
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Map.Map Pattern Matching

2009-05-13 Thread Jochem Berndsen
Nico Rolle wrote:
 Hi

 I tried this but it diddn't work in ghci:

 import qualified Data.Map as Map

 test :: Map.Map [Int] [[Int]] - Bool
 test (fromList[((i:is), (j:js))]) = [i] == j

 i get the : Parse error in pattern
 Failed. error.

Pattern matching only works on constructors (and view patterns, but they
are a bit more advanced.) I'm not sure what you are trying to
accomplish, could you elaborate?

Cheers,
-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe