REMINDER - Contributions to HC&A Report (November 2003 edition)

2003-11-02 Thread Alain Cremieux
Category : Applications, Groups, and Individuals
Subcategory : Individual Haskellers and their projects
I work in a company making software for payrolling, which is a 
incredibly complex subject in France.
I'd like to use Haskell in my everyday's work, but up to now it's only 
been a personal hobby ("passion" woul be more accurate).
I am convinced that embedded languages ("DSEL") have strong applications 
in software-making companies. Of course Haskell is one of the best 
language for that; but if there are many fascinating papers (resulting 
from hard work & deep insights) on the subject, practical reusable code 
lacks. Most projects are unfinished, and when code exists it is in "as 
is" state, and never reusable without much work.
So as a start I am trying to implement How to write a financial contract 
, 
a chapter in "The Fun of Programming" by Simon Peyton Jones & Jean-Marc 
Eber. This article details the full analysis (the hard part) of an 
embedded language application. A deriving implementation should provide 
several solutions, depending on design decisions (for instance a 
"shallow" embedding and a "deep" embedding), simplifications rules 
leading to a (moderately) optimised interpreter and a code generator 
(C-- is my target language). And the code should work (calculate the 
value of several common financial options).
Two other key papers for this work are  Compiling Embedded Languages 
, by Conal Elliott, Sigbjorn 
Finne and Oege de Moor, and Programming Graphics Processors Functionally 
 (Vertigo) by Conal Elliott.
Any advice and/or discussion would be welcome.
Alain Crémieux

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Overloading and Literal Numerics

2002-06-26 Thread Alain Cremieux

Hi,
I am trying to create an overloaded function "à la Java" to be able to
call it either with a string or a number.
Ex :
definePort "http"
definePort 80
but I have problem with restrictions in Haskell's type system (or with
my lack of experience with it).

The program :

data PolyType = MkPolyLeft String | MkPolyRight (String, String) |
MkPolyNum Int deriving Show

class Poly a where
poly :: a -> PolyType

instance Poly String where
poly s = MkPolyLeft s
instance Poly (String, String) where
poly p = MkPolyRight p
instance Poly Int where
poly i = MkPolyNum i

po :: (Poly a) => a -> PolyType
po = poly

tpo1, tpo2, tpo3 :: PolyType
tpo1 = po "35"
tpo2 = po ("36", "37")
tpo3 = po 39


gives the following result  with ghc (5.03 & -fglasgow-exts) :

cl.hs:21:
Ambiguous type variable(s) `a' in the constraint `Poly a'
arising from use of `po' at cl.hs:21
In the definition of `tpo3': po 39

cl.hs:21:
Ambiguous type variable(s) `a' in the constraint `Num a'
arising from the literal `39' at cl.hs:21
In the first argument of `po', namely `39'
In the definition of `tpo3': po 39

I think I need the "closed" extension of the 'class' clause to do that
(but it does not seem to be implemented yet).

Is there a better solution ?
Thank you,
Alain


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell