Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-19 Thread Bruno Oliveira
Hello Conor, I personally think GADTs are a great idea, don't get me wrong. I am not arguing that we should all start programming using on a Church encoding. Neither I am arguing that this encoding can replace GADTs in all cases. Nevertheless, I believe that knowing about this encoding, in the

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-19 Thread Ross Paterson
On Tue, Oct 18, 2005 at 05:51:13PM +0100, Conor McBride wrote: | Neither Oleg nor Bruno translated my code; they threw away my | structurally recursive on-the-fly automaton and wrote combinator parsers | instead. That's why there's no existential, etc. The suggestion that | removing the GADT

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-19 Thread Conor McBride
[EMAIL PROTECTED] wrote: I suspect that once you start producing values with the relevant properties (as I do) rather than just consuming them (as Oleg and Bruno do), the GADT method might work out a little neater. Actually, the code is pretty much your original code, with downcased

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-19 Thread Ross Paterson
On Wed, Oct 19, 2005 at 03:17:41PM +0100, Conor McBride wrote: I was just about to send, when up popped Ross's program, which does give me a datatype, including just enough extra stuff to support functoriality. data RegExp tok a = Zero | One a | Check (tok - a) (tok - Bool)

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-19 Thread Ross Paterson
On Wed, Oct 19, 2005 at 03:17:41PM +0100, Conor McBride wrote: It's nice that the syntax of regular expressions survives, but it has been somewhat spun in favour of the functionality required in the example. I'm not sure about that either -- the existential coding supports elimination too, if

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-18 Thread Bruno Oliveira
Hello, You can also write this code in Haskell 98. Jeremy Gibbons and I have recently written a paper entitled TypeCase: A design pattern for type-indexed functions where we explore the use of some techniques from lightweight approaches to generic programming (Ralf Hinze and James Cheney's work)

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-18 Thread Conor McBride
Hi folks There is nothing ingenious with this solution --- I basically translated Oleg's and Conor's code. Neither Oleg nor Bruno translated my code; they threw away my structurally recursive on-the-fly automaton and wrote combinator parsers instead. That's why there's no existential, etc.

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-18 Thread oleg
Conor McBride wrote: Neither Oleg nor Bruno translated my code; they threw away my structurally recursive on-the-fly automaton and wrote combinator parsers instead. That's why there's no existential, etc. The suggestion that removing the GADT simplifies the code would be better substantiated

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-18 Thread oleg
Conor McBride wrote: Neither Oleg nor Bruno translated my code; they threw away my structurally recursive on-the-fly automaton and wrote combinator parsers instead. That's why there's no existential, etc. The suggestion that removing the GADT simplifies the code would be better substantiated

Re: [Haskell-cafe] Regular Expressions without GADTs

2005-10-17 Thread Ralf Hinze
The code seems a bit simpler, too. Do you really think so? To me replacing a GADT by class and instance declarations seems the wrong way round. We should not forget that the DT in GADT stands for `data type'. One could certainly argue that the gist of functional programming is to define a