On Sun, 10 Jul 2011 11:49:44 +0100, Patrick Browne
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 which has tw
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] ftp://ftp.geoinfo.tuwien.ac
On Sun, Jul 10, 2011 at 06:49, Patrick Browne 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 which has two comp
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
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]):
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,
Pat
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
On Fri, 10 Jun 2011 17:28:22 +0100, Patrick Browne
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 way: It's helpful t
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 thi