[Haskell-cafe] problem with instance method

Tom Nielsen tanielsen at gmail.com
Thu Feb 3 11:27:14 CET 2011


No, obj is a method of the Objects class. you've already declared it
in the instance of Objects Object

your code works just fine here. adding:

> mycar = Car Blue

> o:: Object Car Integer
> o = obj mycar 4

ghci says...

*Objects> :t obj
obj :: (Objects o t i) => t -> i -> o t i
*Objects> o
Obj (Car Blue) 4

But I hope you read my last email in the other thread you started...

Tom

On Thu, Feb 3, 2011 at 10:15 AM, Ivan Lazar Miljenovic
<ivan.miljenovic at gmail.com> wrote:
> On 3 February 2011 21:09, Patrick Browne <patrick.browne at dit.ie> wrote:
>> Hi,
>> I am studying type classes using examples from the literature [1].
>> The attached code is a formalization of basic object oriented ideas. The
>> particular approach seems to be built on the concepts of: thing, object,
>> and identifier.
>> I have no intension to implement anything or significantly change the
>> code below. Rather, I am trying to understand the code as it stands.
>> I include a number of test runs which seem OK, but I cannot get the
>> *obj* function to work.
>>
>> obj :: t -> i -> o t i
>> obj t i = Obj t i
>
> The type signature says "Given any `t' and any `i', this will return
> any `o t i' (for some unspecified type `o')".  However, your actual
> implementation uses a specific data-type, namely Object for `o'.
> Change the type signature to be "obj :: t -> i -> Object t i".
>
> --
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> IvanMiljenovic.wordpress.com
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



More information about the Haskell-Cafe mailing list