Re: Re[6]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
On 4 Jan 2008, at 2:00 AM, Nicholls, Mark wrote: You may be right...but learning is not an atomic thingwherever I start I will get strange things happening. The best place to start learning Haskell is with the simplest type features, not the most complicated. And it's the simplest features that are most unlike OO. Yes, Haskell will be `strange'. But if you think you're `the intersection' between Haskell and OO, you'll think things are familiar, and you'll be surprised when they turn out to be different. I'd concentrate on watching out for differences --- but then I can't imagine how finding `familiar' ideas would help. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Re[6]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
You may be right...but learning is not an atomic thingwherever I start I will get strange things happening. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 18:59 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[6]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 6:40:13 PM, you wrote: it would be hard to understand overlap without knowing both systems. you will believe that you understand it, but things will go strange ways :) I do not necessarily disagree But if I can identify the overlapthen I have leant the overlap...on the cheap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 14:39 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 2:13:08 PM, you wrote: of course *some* overlap exists but in order to understand it you should know exact shape of both methods when i tried to develop complex library without understanding t.c. implementation, i constantly goes into the troubles - things that i (using my OOP experience) considered as possible, was really impossible in Haskell so i'm really wonder why you don't want to learn the topic thoroughly I loosely do understandbut very looselybut I'm not, as yet, convinced it is completely relevant. The implementation may differ, but that does not mean that there is no overlapI am not expecting one model to be a superset of the other, but I am expecting some sort of overlap between 'interface' implementation and type class instance declaration. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 10:54 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
I was thinking more along type classesand then I was going to throw some spanners in the works From: Ryan Ingram [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 17:41 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Of course it depends what's inside the braces, and what you want to do with it, but I'd be inclined to do something like this: 1) data IX a = IX { constructor :: Int - a, ... } 2) data IX a b = IX { constructor :: Int - b, func :: a - b, ... } 3) data IX a b = IX { iy :: IY a, ... } 4) data IX a b = IX { iz :: IZ b, iy :: IY a, ... } Can you specify more clearly what the goal of the conversion is? If you want OO style behavior the thing that is most important is existential quantification. -- ryan On 1/2/08, Nicholls, Mark [EMAIL PROTECTED] wrote: I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
[snip] -- C#: interface IX1 { String foo1(int); } class IX1 obj where foo1 :: Int - obj - String Yep...I think that's what I'd dothough I would have done... foo1 :: obj - Int - String Does that matter? -- C#: interface IX2A { String foo2(A); } class IX2 obj a where foo2 :: a - obj - String Ok same here --C#: interface IX3A where A : IY { String foo3(A); } class IY a where {- ... -} class IY a = IX3 obj a where foo3 :: a - obj - String Yep I think again I would have guessed at that --C#: interface IX4A : IZ where A : IY class IZ a where {- ... -} class (IY a, IZ obj) = IX4 obj a where foo4 :: a - obj - String H...this would have been one of my guessesbut let me have a go... This assumes your objects are immutable, otherwise you would have to return (obj,String) instead of just String and then you most likely want to use the state monad and do notation to make functional programming look more like imperative programming. This is finemy oop is largely immutable. You really have to drop the OO way of thinking, which I find the hardest :) Haskell's type classes are more powerful in some sense than C# interfaces; for example, in C# you can't attach an interface to any class (take for example the Point struct), it has to be your own class, while in Haskell, you can implement an instance of a type class for any datatype! OK but I was going to go onto Interface IXA where A : IXA { } And Interface IXA,B where A : B { } Where I cannot see a way to do the above in Haskell at allas interfaces effectively operator on type classes not typeswhich seems inherently more powerful But if these could be done in Haskell the see what could be made of stuff likewhich is obviously problematic in C# it obviously doesn't workbut potentially does make 'sense'. Interface IXA : A { } Hope this helps a bit. As I'm new myself to Haskell, so take this with a grain of salt. It does...I will have a go with your sample answers. Once you bite the bullet, I found Haskell a lot more fun than C#, although C# of course comes with a gigantic .NET framework and tools... I'm looking at Haskell because of the formality of it's type systembut I'm actually not convinced it is as powerful as an OO onei.e. OO ones operatate principally (in Haskell speak) on type classes not types Peter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
I loosely do understandbut very looselybut I'm not, as yet, convinced it is completely relevant. The implementation may differ, but that does not mean that there is no overlapI am not expecting one model to be a superset of the other, but I am expecting some sort of overlap between 'interface' implementation and type class instance declaration. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 10:54 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Hi Mark, foo1 :: Int - obj - String Yep...I think that's what I'd dothough I would have done... foo1 :: obj - Int - String Does that matter? Well, it's a good habit in Haskell to move the most important parameter to the end of the argument list. See e.g. http://www.haskell.org/haskellwiki/Parameter_order. OK but I was going to go onto Interface IXA where A : IXA {} and Interface IXA,B where A : B {} No, I would not know how to that in Haskell using type classes. It seems Haskell does not allow cycles in type class definitions. But as I'm new, this does not mean it's not possible. It's more important to know *what* you are trying to do, than to give a solution in a different language, since OO and FP are kind of orthogonal languages. Where I cannot see a way to do the above in Haskell at allas interfaces effectively operator on type classes not typeswhich seems inherently more powerful Yeah, kind of makes sense. I liked interfaces in C# a lot, but when I started doing everything with interfaces, I found the lack of support for mixins or default implementations problematic. This ended up in a lot of copy/paste or encapsulating the implementations into a static class with plain functions, a mess. But if these could be done in Haskell the see what could be made of stuff likewhich is obviously problematic in C# it obviously doesn't workbut potentially does make 'sense'. Interface IXA : A {} Ah! That's one of the bigger restrictions in C# yes! C++ can do that; ATL uses it a lot, and I also like that approach. You can emulate mixins with that, and still stay in the single inheritance paradigm. In Haskell you don't do that at all of course, since you avoid thinking about objects and inheritance in the first place. OO is strange. They offer you the nice concept of inheritance, and then the guidelines tell you: don't use too many levels of inheritance... Although I've build huge projects using OO, it always felt a bit like unsafe hacking. I don't really have that feeling with Haskell, but that could also be because I'm too new to the language ;-) I'm looking at Haskell because of the formality of it's type systembut I'm actually not convinced it is as powerful as an OO onei.e. OO ones operatate principally (in Haskell speak) on type classes not types Maybe you are right, I don't know, my theoritical skills are not high enough to answer that. Haskell just feels better to me, although the lack of a friendly productive IDE and large standard framework remains a bit of a burden. Good luck, Peter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Ahh ok I see what is meant by the parameter order -Original Message- From: Peter Verswyvelen [mailto:[EMAIL PROTECTED] On Behalf Of Peter Verswyvelen Sent: 03 January 2008 12:02 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hi Mark, foo1 :: Int - obj - String Yep...I think that's what I'd dothough I would have done... foo1 :: obj - Int - String Does that matter? Well, it's a good habit in Haskell to move the most important parameter to the end of the argument list. See e.g. http://www.haskell.org/haskellwiki/Parameter_order. OK but I was going to go onto Interface IXA where A : IXA {} and Interface IXA,B where A : B {} No, I would not know how to that in Haskell using type classes. It seems Haskell does not allow cycles in type class definitions. But as I'm new, this does not mean it's not possible. It's more important to know *what* you are trying to do, than to give a solution in a different language, since OO and FP are kind of orthogonal languages. Where I cannot see a way to do the above in Haskell at allas interfaces effectively operator on type classes not typeswhich seems inherently more powerful Yeah, kind of makes sense. I liked interfaces in C# a lot, but when I started doing everything with interfaces, I found the lack of support for mixins or default implementations problematic. This ended up in a lot of copy/paste or encapsulating the implementations into a static class with plain functions, a mess. But if these could be done in Haskell the see what could be made of stuff likewhich is obviously problematic in C# it obviously doesn't workbut potentially does make 'sense'. Interface IXA : A {} Ah! That's one of the bigger restrictions in C# yes! C++ can do that; ATL uses it a lot, and I also like that approach. You can emulate mixins with that, and still stay in the single inheritance paradigm. In Haskell you don't do that at all of course, since you avoid thinking about objects and inheritance in the first place. OO is strange. They offer you the nice concept of inheritance, and then the guidelines tell you: don't use too many levels of inheritance... Although I've build huge projects using OO, it always felt a bit like unsafe hacking. I don't really have that feeling with Haskell, but that could also be because I'm too new to the language ;-) I'm looking at Haskell because of the formality of it's type systembut I'm actually not convinced it is as powerful as an OO onei.e. OO ones operatate principally (in Haskell speak) on type classes not types Maybe you are right, I don't know, my theoritical skills are not high enough to answer that. Haskell just feels better to me, although the lack of a friendly productive IDE and large standard framework remains a bit of a burden. Good luck, Peter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Hello Mark, Thursday, January 3, 2008, 2:13:08 PM, you wrote: of course *some* overlap exists but in order to understand it you should know exact shape of both methods when i tried to develop complex library without understanding t.c. implementation, i constantly goes into the troubles - things that i (using my OOP experience) considered as possible, was really impossible in Haskell so i'm really wonder why you don't want to learn the topic thoroughly I loosely do understandbut very looselybut I'm not, as yet, convinced it is completely relevant. The implementation may differ, but that does not mean that there is no overlapI am not expecting one model to be a superset of the other, but I am expecting some sort of overlap between 'interface' implementation and type class instance declaration. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 10:54 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
I do not necessarily disagree But if I can identify the overlapthen I have leant the overlap...on the cheap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 14:39 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 2:13:08 PM, you wrote: of course *some* overlap exists but in order to understand it you should know exact shape of both methods when i tried to develop complex library without understanding t.c. implementation, i constantly goes into the troubles - things that i (using my OOP experience) considered as possible, was really impossible in Haskell so i'm really wonder why you don't want to learn the topic thoroughly I loosely do understandbut very looselybut I'm not, as yet, convinced it is completely relevant. The implementation may differ, but that does not mean that there is no overlapI am not expecting one model to be a superset of the other, but I am expecting some sort of overlap between 'interface' implementation and type class instance declaration. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 10:54 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
On 3 Jan 2008, at 7:40 AM, Nicholls, Mark wrote: I do not necessarily disagree But if I can identify the overlapthen I have leant the overlap...on the cheap. Not really. You still don't have the context which allows you to fit the Haskell features into a complete system. Meaning is derived from context, it's not inherent --- and the meaning and use of even those features that translate between Haskell and C++ is completely different, because the context they need to fit into makes them suitable for different sorts of applications. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[6]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Hello Mark, Thursday, January 3, 2008, 6:40:13 PM, you wrote: it would be hard to understand overlap without knowing both systems. you will believe that you understand it, but things will go strange ways :) I do not necessarily disagree But if I can identify the overlapthen I have leant the overlap...on the cheap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 14:39 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 2:13:08 PM, you wrote: of course *some* overlap exists but in order to understand it you should know exact shape of both methods when i tried to develop complex library without understanding t.c. implementation, i constantly goes into the troubles - things that i (using my OOP experience) considered as possible, was really impossible in Haskell so i'm really wonder why you don't want to learn the topic thoroughly I loosely do understandbut very looselybut I'm not, as yet, convinced it is completely relevant. The implementation may differ, but that does not mean that there is no overlapI am not expecting one model to be a superset of the other, but I am expecting some sort of overlap between 'interface' implementation and type class instance declaration. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 03 January 2008 10:54 To: Nicholls, Mark Cc: Bulat Ziganshin; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Thursday, January 3, 2008, 1:22:26 PM, you wrote: because they have different models. i recommend you to start from learning this model, otherwise you will don't understand how Haskell really works and erroneously apply your OOP knowledge to Haskell data structures. shortly said, there are 3 ways to polymorphism: 1) C++ templates - type-specific code generated at compile time 2) OOP classes - every object carries VMT which allows to select type-specific operation 3) type classes - dictionary of type-specific operations is given as additional hidden argument to each function Haskell uses t.c. and its abilities are dictated by this implementation. there is no simple and direct mapping between features provided by OOP and t.c. Can you give me a summary of why it's meaningless.both would seem to describe/construct values/objectsthey may not be equivalent, but I would expect some considerable overlap. -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 02 January 2008 20:29 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Peter Verswyvelen [EMAIL PROTECTED] writes: Well, it's a good habit in Haskell to move the most important parameter to the end of the argument list. See e.g. http://www.haskell.org/haskellwiki/Parameter_order. I must say I like these recommendations. As for the Data.Map examples, the parameter order was changed compared to the old FiniteMap, and I was sure there was some rationale given? -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Of course it depends what's inside the braces, and what you want to do with it, but I'd be inclined to do something like this: 1) data IX a = IX { constructor :: Int - a, ... } 2) data IX a b = IX { constructor :: Int - b, func :: a - b, ... } 3) data IX a b = IX { iy :: IY a, ... } 4) data IX a b = IX { iz :: IZ b, iy :: IY a, ... } Can you specify more clearly what the goal of the conversion is? If you want OO style behavior the thing that is most important is existential quantification. -- ryan On 1/2/08, Nicholls, Mark [EMAIL PROTECTED] wrote: I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
Hello Mark, Wednesday, January 2, 2008, 7:40:31 PM, you wrote: I'm trying to translate some standard C# constucts into Haskell... some it's meaningless. read http://haskell.org/haskellwiki/OOP_vs_type_classes and especially papers mentioned in the References -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
FW: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?
I'm also new to Haskell, but I'm a C++/C# veteran, so I'll give it a shot. C#'s interfaces look a bit like Haskell's type classes. Although not exactly the same, you could try something like this: -- C#: interface IX1 { String foo1(int); } class IX1 obj where foo1 :: Int - obj - String -- C#: interface IX2A { String foo2(A); } class IX2 obj a where foo2 :: a - obj - String --C#: interface IX3A where A : IY { String foo3(A); } class IY a where {- ... -} class IY a = IX3 obj a where foo3 :: a - obj - String --C#: interface IX4A : IZ where A : IY class IZ a where {- ... -} class (IY a, IZ obj) = IX4 obj a where foo4 :: a - obj - String The C# class is called an instance in Haskell, so to implement an interface, you would do e.g. data X2 = X2 { x2Bla :: String, ... } instance IX2 X2 String where foo2 s o = (x2Bla o) ++ s This assumes your objects are immutable, otherwise you would have to return (obj,String) instead of just String and then you most likely want to use the state monad and do notation to make functional programming look more like imperative programming. You really have to drop the OO way of thinking, which I find the hardest :) Haskell's type classes are more powerful in some sense than C# interfaces; for example, in C# you can't attach an interface to any class (take for example the Point struct), it has to be your own class, while in Haskell, you can implement an instance of a type class for any datatype! Hope this helps a bit. As I'm new myself to Haskell, so take this with a grain of salt. Once you bite the bullet, I found Haskell a lot more fun than C#, although C# of course comes with a gigantic .NET framework and tools... Peter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark Sent: Wednesday, January 02, 2008 5:41 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell? I'm trying to translate some standard C# constucts into Haskell... some of this seems easy Specifically 1) Interface IX { } 2) Interface IXA { } 3) Interface IXA Where A : IY { } 4) Interface IXA : IZ Where A : IY { } I can take a punt at the first 2but then it all falls apart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe