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

Max Rabkin max.rabkin at gmail.com
Wed May 13 13:15:51 EDT 2009


On Wed, May 13, 2009 at 7:06 PM, Nico Rolle <nrolle at 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


More information about the Haskell-Cafe mailing list