[Haskell-cafe] Pattern matching with OverloadedLists
vlatko.basic at gmail.com
Fri Nov 6 16:35:09 UTC 2015
I was only wondering why doesn't that work.
The two functions were just an example of how I thought OverloadedLists
I got an answer on irc that ':' constructor is not desugared, but I expected it is.
Compiler can see when overloading is for "real" list and skip it, preserving
> -------- Original Message --------
> Subject: Re: [Haskell-cafe] Pattern matching with OverloadedLists
> From: Alejandro Serrano Mena <trupill at gmail.com>
> To: vlatko.basic at gmail.com
> Cc: haskell-cafe <Haskell-cafe at haskell.org>
> Date: 06/11/15 16:38
> You need to write `toList` in both branches:
> f (toList -> ('9':_)) = 1
> f (toList -> ('1':_)) = 2
> 2015-11-06 16:20 GMT+01:00 Vlatko Basic <vlatko.basic at gmail.com
> <mailto:vlatko.basic at gmail.com>>:
> Hello Cafe,
> wiki for OverloadedLists says that
> g [x,y,z] = ...
> is treated as
> g (toList-> [x,y,z]) =
> Shouldn't this work? Both 'f's should be treated the same.
> f :: Text -> Int
> f (toList -> ('9':_)) = 1 -- OK
> f ('1':_) = 2 -- Couldn't match expected type ‘Text’
> with actual type ‘[Char]’
> (OverloadedStrings is also on)
> Am I missing something?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe