Re: [Haskell-cafe] unary pattern matching

2006-01-27 Thread Brian Hulley
John Meacham wrote: On Fri, Jan 27, 2006 at 12:28:23PM +1100, Donald Bruce Stewart wrote: john: I have often wanted a shorthand syntax for testing if a value matches a given pattern. I want to implement such an extension for jhc but can't decide an appropriate syntax so I thought I'd ask the

Re: [Haskell-cafe] unary pattern matching

2006-01-27 Thread Cale Gibbard
On 27/01/06, Brian Hulley [EMAIL PROTECTED] wrote: John Meacham wrote: On Fri, Jan 27, 2006 at 12:28:23PM +1100, Donald Bruce Stewart wrote: john: I have often wanted a shorthand syntax for testing if a value matches a given pattern. I want to implement such an extension for jhc but

[Haskell-cafe] Another idea for record field selection and better namespace management

2006-01-27 Thread Brian Hulley
Hi - To avoid the problems with so many names being put into a module's namespace, data declarations could implicitly define sub-modules and class/instance declarations as follows: module M where data Foo = FooCon {x : Int} would declare (as seen from inside M) Foo, Foo.FooCon,

Re: [Haskell-cafe] Another idea for record field selection and betternamespace management

2006-01-27 Thread Brian Hulley
Apologies - I've noticed some mistakes corrected as follows: Brian Hulley wrote: class //x a b where x : a - b class //FooCon a b where FooCon : a - b class //x a b | a - b where-- I think this fundep is correct x :: a-b

Re: [Haskell-cafe] Known Unknowns

2006-01-27 Thread Chris Kuklewicz
Joel Koerwer wrote: On 1/26/06, *Donald Bruce Stewart* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Ah, i just do: ghc A.hs -O2 -ddump-simpl | less and then read the Core, keeping an eye on the functions I'm interested in, and checking they're compiling to the kind of

Re: [Haskell-cafe] Another idea for record field selection and betternamespace management

2006-01-27 Thread Brian Hulley
Another correction... Brian Hulley wrote: data Col1 a = One a data Col2 a = One a | Two a useOne :: ( //One col a) = col - a useOne (One x) = x should be useOne :: (//One a col) = col - a ___ Haskell-Cafe

[Haskell-cafe] arr f

2006-01-27 Thread Sven Biedermann
Dear Haskellers, since this is my first post, "Hello all" I have a problem with a function taken from class Arrow. arr :: (b - c) - a b c To build my own arrow, i need to distinguish between different kinds of b or c. For instance, if bhas the form(d,e), i want to construct

Re: [Haskell-cafe] arr f

2006-01-27 Thread Henrik Nilsson
Hi Sven, since this is my first post, Hello all Welcome! I have a problem with a function taken from class Arrow. arr :: (b - c) - a b c To build my own arrow, i need to distinguish between different kinds of b or c. For instance, if b has the form (d,e), i want to construct

Re: [Haskell-cafe] arr f

2006-01-27 Thread Ross Paterson
On Fri, Jan 27, 2006 at 08:20:07PM +0100, Sven Biedermann wrote: I have a problem with a function taken from class Arrow. arr :: (b - c) - a b c To build my own arrow, i need to distinguish between different kinds of b or c. For instance, if b has the form (d,e), i want to

[Haskell-cafe] Evaluating arithmetic expressions at run time

2006-01-27 Thread Andrew Savige
Haskell beginner using GHC. I have a function to do some simple arithmetic at run time: myeval :: Int - Int - String - Int myeval x y + = (+) x y myeval x y - = (-) x y myeval x y * = (*) x y -- ... While that works, I'm curious to know if it can be done more elegantly. I'm thinking of

Re: [Haskell-cafe] Evaluating arithmetic expressions at run time

2006-01-27 Thread Ben Lippmeier
Andrew Savige wrote: Haskell beginner using GHC. Hello there! How about, opTable = [ (+, (+)) , (-, (-)) ... ] myeval x y op = let Just fun = lookup op opTable in x `fun` y ? I have a function to do some simple arithmetic at run time: myeval :: Int - Int - String - Int

Re: [Haskell-cafe] Evaluating arithmetic expressions at run time

2006-01-27 Thread Ben Lippmeier
BTW: There isn't an easy way to magically derive opTable. We're relying on the fact that these simple functions all have the same type. Ben Lippmeier wrote: opTable = [ (+, (+)) , (-, (-)) ... ] myeval x y op = letJust fun = lookup op opTable in x `fun` y You could also

Re: [Haskell-cafe] Evaluating arithmetic expressions at run time

2006-01-27 Thread Cale Gibbard
On 28/01/06, Andrew Savige [EMAIL PROTECTED] wrote: Haskell beginner using GHC. I have a function to do some simple arithmetic at run time: myeval :: Int - Int - String - Int myeval x y + = (+) x y myeval x y - = (-) x y myeval x y * = (*) x y -- ... While that works, I'm curious to