
7 Aug
2011
7 Aug
'11
5:36 a.m.
On Sun, 07 Aug 2011 08:08:31 +0200, Antoine Latter
You can use non-standard GHC extensions:
Given a function:
someView :: Natural a -> a
you can pattern match like so:
case myNat of (someView -> 5) -> "It's a five!!!"
This requires {-# LANGUAGE ViewPatterns #-} at the top of your source file to enable.
Not using any extension: case fromNatural myNat of 5 -> "It's a five!!!" The function fromNatural is, of course, imported from the module defining Natural. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --