[Haskell-cafe] order of arguments matters
Peter Padawitz
peter.padawitz at udo.edu
Fri Mar 18 09:37:07 CET 2011
Why does only tr2 work, although the only difference between tr1 and
tr2 is the order of arguments?
import Data.Tree (Tree(..))
data Type a where Tree :: Type a -> Type (Tree a)
Int :: Type Int
String :: Type String
type Traversal1 = forall a.a -> Type a -> a
type Traversal2 = forall a.Type a -> a -> a
tr1 :: Traversal1
tr1 (Node _ (t:_)) (Tree Int) = Node 1 [t]
tr1 n Int = n+n
tr1 s String = s++s
tr2 :: Traversal2
tr2 (Tree Int) (Node _ (t:_)) = Node 1 [t]
tr2 Int n = n+n
tr2 String s = s++s
Couldn't match expected type `a' against inferred type `Tree Int'
`a' is a rigid type variable bound by
the type signature for `tr1' at tratest.hs:9:25
In the pattern: Node _ (t : _)
In the definition of `tr1':
tr1 (Node _ (t : _)) (Tree Int) = Node 1 [t]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110318/28bd0494/attachment.htm>
More information about the Haskell-Cafe
mailing list