Re: new haskell project (Was Re: [Haskell-cafe] Subtype polymorphism in Haskell)

2010-07-10 Thread Simon Courtenage
Hi Daniel, Thanks for getting in touch - I would recommend, if you are interested in the project, that you join the project mailing lists, and let me know your sourceforge account name so I can add you to the project membership list. About the design question that you raise. The aim is to

Re: new haskell project (Was Re: [Haskell-cafe] Subtype polymorphism in Haskell)

2010-07-10 Thread Edward Kmett
On Sat, Jul 10, 2010 at 2:15 PM, Simon Courtenage courten...@gmail.comwrote: Hi Daniel, Thanks for getting in touch - I would recommend, if you are interested in the project, that you join the project mailing lists, and let me know your sourceforge account name so I can add you to the

Re: new haskell project (Was Re: [Haskell-cafe] Subtype polymorphism in Haskell)

2010-07-09 Thread Daniel Cook
Hi Simon, I'm interested in this as well (you might have seen my other posts about getting QuickFIX interfaced with Haskell). One question (Yitzchak raises a valid point): Why port QuantLib's structure rather than directly build an idiomatic Haskell quantitative finance library? Especially

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-06 Thread Simon Courtenage
My thanks to everyone who replied with their helpful comments. You are right that I forgot to add the public inheritance on the C++ classes (that's what happens when you write code in an email without passing it through a compiler first). I like the idea below, which is easy to understand. It

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-06 Thread Yitzchak Gale
Simon Courtenage wrote: I am porting a C++ program to Haskell.  My current task is to take a class hierarchy and produce something equivalent in Haskell Did you define that task for yourself, or is someone else asking you to do it? There really isn't anything equivalent in Haskell. Typeclasses

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-06 Thread Miguel Mitrofanov
Actually, I liked Tillmann Rendel's idea much better than my own one: data A = A {do_x :: Int - Int - Int} b = A {do_x = \x y - ...} c = A {do_x = \x y - ...} Simon Courtenage wrote: My thanks to everyone who replied with their helpful comments. You are right that I forgot to add the public

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-06 Thread Yitzchak Gale
Simon Courtenage wrote: This is for a project to port an open-source C++ library to haskell. Great! We'd love to give you whatever support you need for your efforts.  My initial plan is to more or less preserve the way the library works in the first draft of the port and see how far we can

new haskell project (Was Re: [Haskell-cafe] Subtype polymorphism in Haskell)

2010-07-06 Thread Simon Courtenage
Hi, Just to add some details about the project I'm working on in case anyone is interested. The project is called Quanthas and is being hosted on sourceforge at http://sourceforge.net/projects/quanthas/. The aim of the project is to produce a Haskell implementation of Quantlib (

[Haskell-cafe] Subtype polymorphism in Haskell

2010-07-05 Thread Simon Courtenage
Hi, I am porting a C++ program to Haskell. My current task is to take a class hierarchy and produce something equivalent in Haskell, but I don't seem to be able to get a grip on how type classes and instances contribute to the solution. Can anyone enlighten me? Roughly, the class hierarchy in

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-05 Thread Miguel Mitrofanov
My guess is that it's class B : public A and class C : public A In this case it seems perfect to use type classes: class A t where do_x :: t - Integer - Integer - Integer data B = ... instance A B where do_x b x y = ... data C = ... instance A C where do_x c x y = ... If you want some general

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-05 Thread Daniel Fischer
On Monday 05 July 2010 15:22:43, Simon Courtenage wrote: Hi, I am porting a C++ program to Haskell. My current task is to take a class hierarchy and produce something equivalent in Haskell, but I don't seem to be able to get a grip on how type classes and instances contribute to the

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-05 Thread aditya siram
Does this work for you? data A a = A (Int,Int) data B data C class A_Class a where do_x :: a - Int instance A_Class (A B) where do_x (A (a,b)) = a + b instance A_Class (A C) where do_x (A (a,b)) = a - b -- do_x ((A (1,2)) :: A B) -- 3 -- do_x ((A (1,2)) :: A C) -- -1 -deech On Mon,

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-05 Thread Tillmann Rendel
Simon Courtenage wrote: I am porting a C++ program to Haskell. My current task is to take a class hierarchy and produce something equivalent in Haskell, but I don't seem to be able to get a grip on how type classes and instances contribute to the solution. They probably do not contribute

Re: [Haskell-cafe] Subtype polymorphism in Haskell

2010-07-05 Thread Yves Parès
data A_GADT where A_GADT :: A t = t - A_GADT By the way, is there an extension that enables A_GADT to be automatically declared as an instance of class A? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org