Re: Bug in PAKCS data inspection ¿?

From: Bernd Brassel <bbr_at_informatik.uni-kiel.de>
Date: Thu, 25 Oct 2007 10:24:39 +0200

Juan Carlos González Moreno schrieb:
> Hi everybody,
> this week an student report me de following code:
>
> infixr 5 :<
> data Seq a = a | a :< Seq a
>
> crear :: Seq Int
> crear = 1 :< (2 :< 3)
>
> --Devolver primer elemento
> devolPrimero :: Seq Int -> Int
> devolPrimero (a :< _) = a
>
> goal :: Int
> goal = devolPrimero crear
>
> i know it is clear the problem with it but the error that PAKCS shows is:
>
> Parsing 'local.curry'...
> generating local.fcy ...
> cymake:
> "local.curry", line 6.9: Type error in infix application
> 2 :< 3
> Term: 3
> Inferred type: Prelude.Int
> Expected type: Seq Prelude.Int
> Types Seq Prelude.Int and Prelude.Int are incompatible
> ERROR occurred during parsing!
>
> The question is why PAKCS no detect that the problem is with data
> definition ¿?
>
> data Seq a = a | a :< Seq a

Quite a funny program. The reason for the problem is that
this Declaration defines a constructor named "a".

So if you change the definition of crear to:

crear :: Seq Int
crear = 1 :< (2 :< a)

you now get the error:
"local.curry", line 9.1: Type error in function binding
Function: devolPrimero
Inferred type: Seq (Seq _7) -> Seq _9
Expected type: Seq Prelude.Int -> Prelude.Int
Types Prelude.Int and Seq _9 are incompatible

and that is because now the "a" in the function devolPrimero is not a
variable as expected. If you change that also to:

devolPrimero :: Seq Int -> Int
devolPrimero (x :< _) = x

the program compiles and goal evaluates to 1.
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Thu Oct 25 2007 - 12:24:51 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 20 2019 - 07:15:06 CEST