Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Type unions (Russ Abbott)
2. Re: Equivalent of inheritance in Haskell (C K Kashyap)
3. Re: Equivalent of inheritance in Haskell (dan portin)
----------------------------------------------------------------------
Message: 1
Date: Tue, 14 Dec 2010 15:29:27 -0800
From: Russ Abbott <[email protected]>
Subject: Re: [Haskell-beginners] Type unions
To: Ozgur Akgun <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thanks for the references. Glad to see this isn't an unreasonable wish.
*
-- Russ *
On Tue, Dec 14, 2010 at 2:15 PM, Ozgur Akgun <[email protected]> wrote:
> This reminds me of an old thread started by, well me :)
>
> http://www.haskell.org/pipermail/haskell-cafe/2010-March/074805.html(sorry
> for the typos)
>
> It is not an especially enlightening thread, but contains some nice
> references.
>
> HTH,
>
> On 14 December 2010 20:09, Russ Abbott <[email protected]> wrote:
>
>> Is there a way to get this to work?
>>
>> data A = Aconstructor Int
>> data B = Bconstructor Int
>> data AorB = A | B
>>
>> f :: Int -> AorB
>> f x
>> | even x = Aconstructor x
>> | otherwise = Bconstructor x
>>
>> I get this diagnostic.
>>
>> Couldn't match expected type `AorB' against inferred type `A'
>>
>>
>> Since AorB is A or B, why is this not permitted?
>>
>> If instead I write
>>
>> data AorB = Aconstructor Int | Bconstructor Int
>>
>>
>> everything works out ok. But what if I want separate types for A and B?
>>
>> Thanks,
>> *
>> -- Russ *
>>
>>
> --
> Ozgur Akgun
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101214/2594e6d2/attachment-0001.htm>
------------------------------
Message: 2
Date: Wed, 15 Dec 2010 08:55:53 +0530
From: C K Kashyap <[email protected]>
Subject: Re: [Haskell-beginners] Equivalent of inheritance in Haskell
To: Antoine Latter <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Thanks Antoine,
> Is there a particular problem you're trying to solve? we might be able
> to take the conversation in a less speculative direction.
>
At this point its academic ... I have programmed in OOPS for a long
time so, I just wanted to understand how one would go around something
like that in Haskell.
I came across something called the expression problem and it talks
about "open data type" - is this the solution?
Regards,
Kashyap
------------------------------
Message: 3
Date: Tue, 14 Dec 2010 22:43:00 -0800
From: dan portin <[email protected]>
Subject: Re: [Haskell-beginners] Equivalent of inheritance in Haskell
To: C K Kashyap <[email protected]>, [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
You might be interested in Oleg's paper Haskell's Overlooked Object
System<http://homepages.cwi.nl/%7Eralf/OOHaskell/code.html>,
although programming in an object-oriented style is neither elegant nor
idiomatic Haskell. Aside from the actual embedding of an object-oriented
language inside Haskell, the main benefit of the paper is the opening survey
of approaches to object-oriented style programming in Haskell. Not
surprisingly, however, encapsulation and subtyping are the most difficult
concepts from object-oriented languages to capture with Haskell type classes
and algebraic data types.
On Tue, Dec 14, 2010 at 7:25 PM, C K Kashyap <[email protected]> wrote:
> Thanks Antoine,
>
> > Is there a particular problem you're trying to solve? we might be able
> > to take the conversation in a less speculative direction.
> >
> At this point its academic ... I have programmed in OOPS for a long
> time so, I just wanted to understand how one would go around something
> like that in Haskell.
>
> I came across something called the expression problem and it talks
> about "open data type" - is this the solution?
>
> Regards,
> Kashyap
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101214/6e369c61/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 30, Issue 31
*****************************************