[Haskell-cafe] Partial pattern matching
John Van Enk
vanenkj at gmail.com
Mon Mar 9 13:54:20 EDT 2009
You can use the record syntax to get around some of this:
data P { first :: Int, second :: Int }
firstCoord (P {first = f}) = f
2009/3/9 Peter Verswyvelen <bugfact at gmail.com>
> In Haskell, a data constructor can be used partially applied:
> data Pair a b = P a b
>
> f = P 1
>
> however, I cannot do "partial pattern matching", e.g
>
> firstCoord (P x) = x
>
> does not work.
>
> I guess a very important reason must exist why this is the case?
>
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
--
/jve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090309/f0529598/attachment.htm
More information about the Haskell-Cafe
mailing list