On Dec 21, 2007 4:39 AM, Ronald Guida <[EMAIL PROTECTED]> wrote:
> Finally, I tried to define vecLength, but I am getting an error.
>
>  > vecLength :: (Peano s) => Vec s t -> Int
>  > vecLength _ = pToInt (pGetValue :: s)

The s in (pGetValue :: s) is different from the s in (Peano s).  Use
the "scoped type variables" extension:

  vecLength :: forall s. (Peano s) => Vec s t -> Int
  vecLength _ = pToInt (pGetValue :: s)

The forall introduces a scope for s, which type signatures usually do not.

Luke

> < Could not deduce (Peano s1) from the context ()
> <   arising from a use of `pGetValue'
> < Possible fix:
> <   add (Peano s1) to the context of the polymorphic type `forall s. s'
> < In the first argument of `pToInt', namely `(pGetValue :: s)'
> < In the expression: pToInt (pGetValue :: s)
> < In the definition of `vecLength':
> <     vecLength _ = pToInt (pGetValue :: s)
>
> Any suggestions?
> -- Ron
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to