[Haskell-cafe] class and instance

2011-07-10 Thread Patrick Browne
Hi, I am trying to understand the following code. I have written my current (mis-)understanding and questions below. I do not wish to improve the code, it is from a research paper[1] that I am trying to understand. Pat [1] ftp://ftp.geoinfo.tuwien.ac.at/medak/phdmedak.pdf -- A specification. The

Re: [Haskell-cafe] class and instance

2011-07-10 Thread Brandon Allbery
On Sun, Jul 10, 2011 at 06:49, Patrick Browne patrick.bro...@dit.ie wrote: My main question is in understanding the relationship between the arguments of the functions getX and getY in the class and in the instance. It seems to me that the constructor Pt 1 2 produces one element of type Point

Re: [Haskell-cafe] class and instance

2011-07-10 Thread Steffen Schuldenzucker
On 07/10/2011 12:49 PM, Patrick Browne wrote: Hi, I am trying to understand the following code. I have written my current (mis-)understanding and questions below. I do not wish to improve the code, it is from a research paper[1] that I am trying to understand. Pat [1]

Re: [Haskell-cafe] class and instance

2011-07-10 Thread Daniel Schoepe
On Sun, 10 Jul 2011 11:49:44 +0100, Patrick Browne patrick.bro...@dit.ie wrote: My main question is in understanding the relationship between the arguments of the functions getX and getY in the class and in the instance. It seems to me that the constructor Pt 1 2 produces one element of type

Re: [Haskell-cafe] Class and Instance

2011-06-11 Thread Patrick Browne
Thanks for the feedback. I have two further questions 1. Why is it that the Containers class signature does not allow instances to be list of list? I suspect it is because x is a constructor. 2. How would I change the Containers class signature to allow instances to be lists of lists. Thanks,

Re: [Haskell-cafe] Class and Instance

2011-06-11 Thread Daniel Patterson
The problem is that [] alone is not a concrete type - that is what the error is saying, that [] needs to be applied to another type to yield a concrete type. IE, you need a list of something, not just the idea of a list. That something can be polymorphic, so the following works (note the [a]):

[Haskell-cafe] Class and Instance

2011-06-10 Thread Patrick Browne
Hi Below is a class that I wish to create some instances of. I do not wish to change the class definition. It is supposed to represent containers of type x that contain things of type y. My attempt at the insert function seems ok for Char and lists, but not ok for Integer. How do I instantiate

Re: [Haskell-cafe] Class and Instance

2011-06-10 Thread Daniel Schoepe
On Fri, 10 Jun 2011 17:28:22 +0100, Patrick Browne patrick.bro...@dit.ie wrote: -- Not OK -- insert 2 [9,2] This causes an error, because numeric literals like 2 are polymorphic: :t 2 2 :: Num a = a If you fix the type to Integer, it works as expected: insert (2 :: Integer) [9,2] By the

Re: [Haskell-cafe] Class and Instance

2011-06-10 Thread Yves Parès
You can also modify you class if your intent is that it always work with polymorph types (And it will save you some trouble with functional dependencies between types x and y. Plus, it will be Haskell98 compliant) -- insert, remove and whatsIn are then supposed to work *forall y*, and then impose