Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-04 Thread Heinrich Apfelmus
Yitzchak Gale wrote: Eric Mertens wrote: (but I've had my head in Agda lately) Indeed, coming across this problem tempted me to abandon the real world and take refuge in Agda. http://hpaste.org/44469/software_stack_puzzle Wow, so simple, and no higher-rank types! This is the best solution

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-04 Thread Heinrich Apfelmus
Yves Parès wrote: Okay thanks I got the difference between both. The 'exists' syntax seems very useful. Is it planned to be added to GHC in a near future? Probably not. But once GADTs become more prominent, there might be pressure to add first-class existential types to the language. Note

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-03 Thread Eric Mertens
There were a number of emails discussing what a type-safe list solution would like look. This was the approach that first came to mind when I read your email (but I've had my head in Agda lately) http://hpaste.org/44469/software_stack_puzzle I've written up a minimal working example of this

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-03 Thread Yitzchak Gale
Brandon Moore wrote: This code produces and uses a table of all allowed combinations. I think this makes it easier to understand why the code works (and is H98). It's just as easy to make a direct version that produces one requested composition in linear time, so I haven't worried whether

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-03 Thread Yitzchak Gale
Eric Mertens wrote: (but I've had my head in Agda lately) Indeed, coming across this problem tempted me to abandon the real world and take refuge in Agda. http://hpaste.org/44469/software_stack_puzzle Wow, so simple, and no higher-rank types! This is the best solution yet. I am now truly in

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-03 Thread Brandon Moore
From: Yitzchak Gale g...@sefer.org Brandon Moore wrote: This code produces and uses a table of all allowed combinations. I think this makes it easier to understand why the code works (and is H98). It's just as easy to make a direct version that produces one requested composition in

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-03 Thread Yitzchak Gale
Brandon Moore wrote: My solution does not serialize and deserialize between every pair of layers. Ahhh, I see! Sorry I didn't look closely enough the first time. Yes, this is a very nice Haskell 98 solution! This code produces and uses a table of all allowed combinations. I think this makes

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-02 Thread Yitzchak Gale
Thanks to everyone for the nice solutions to this puzzle, here and on reddit: http://www.reddit.com/r/haskell/comments/fu6el/a_practical_haskell_puzzle/ There were two basic approaches. One was to use GADTs and higher-rank types to reduce the amount of type trickery needed. One nice example is

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-02 Thread Yves Parès
Okay thanks I got the difference between both. The 'exists' syntax seems very useful. Is it planned to be added to GHC in a near future? 2011/2/28 Heinrich Apfelmus apfel...@quantentunnel.de Yves Parès wrote: takeC :: Int - Compoz a b - (exists c. Compoz a c) dropC :: Int - Compoz a b -

Re: [Haskell-cafe] A practical Haskell puzzle

2011-03-02 Thread Brandon Moore
From: Yitzchak Gale g...@sefer.org To: haskell-cafe@haskell.org Cc: Heinrich Apfelmus apfel...@quantentunnel.de; Lennart Augustsson lennart.augusts...@gmail.com Sent: Wed, March 2, 2011 9:45:15 AM Subject: Re: [Haskell-cafe] A practical Haskell puzzle Thanks to everyone for the nice

Re: [Haskell-cafe] A practical Haskell puzzle

2011-02-28 Thread Heinrich Apfelmus
Yitzchak Gale wrote: You have written a large software system in Haskell. Wishing to play to Haskell's strength, you have structured your system as a series of composable layers. So you have data types Layer1, Layer2, ... and functions layer2 :: Layer1 - Layer2 layer3 :: Layer2 - Layer3

Re: [Haskell-cafe] A practical Haskell puzzle

2011-02-28 Thread Yves Parès
takeC :: Int - Compoz a b - (exists c. Compoz a c) dropC :: Int - Compoz a b - (exists c. Compoz c b) What does 'exists' means? To create a rank-2 type can't you use: takeC :: Int - Compoz a b - (forall c. Compoz a c) ?? 2011/2/28 Heinrich Apfelmus apfel...@quantentunnel.de Yitzchak Gale

Re: [Haskell-cafe] A practical Haskell puzzle

2011-02-28 Thread wren ng thornton
On 2/28/11 6:01 AM, Yves Parès wrote: takeC :: Int - Compoz a b - (exists c. Compoz a c) dropC :: Int - Compoz a b - (exists c. Compoz c b) What does 'exists' means? To create a rank-2 type can't you use: takeC :: Int - Compoz a b - (forall c. Compoz a c) ?? For any A and T,

Re: [Haskell-cafe] A practical Haskell puzzle

2011-02-28 Thread wren ng thornton
On 2/28/11 2:43 AM, Yitzchak Gale wrote: You have written a large software system in Haskell. Wishing to play to Haskell's strength, you have structured your system as a series of composable layers. So you have data types Layer1, Layer2, ... and functions layer2 :: Layer1 - Layer2 layer3 ::

Re: [Haskell-cafe] A practical Haskell puzzle

2011-02-28 Thread Gábor Lehel
On Mon, Feb 28, 2011 at 12:41 PM, wren ng thornton w...@freegeek.org wrote: On 2/28/11 2:43 AM, Yitzchak Gale wrote: You have written a large software system in Haskell. Wishing to play to Haskell's strength, you have structured your system as a series of composable layers. So you have data

Re: [Haskell-cafe] A practical Haskell puzzle

2011-02-28 Thread Heinrich Apfelmus
Yves Parès wrote: takeC :: Int - Compoz a b - (exists c. Compoz a c) dropC :: Int - Compoz a b - (exists c. Compoz c b) What does 'exists' means? To create a rank-2 type can't you use: takeC :: Int - Compoz a b - (forall c. Compoz a c) ?? Ah, (exists c. Compoz a c) means There exists a

[Haskell-cafe] A practical Haskell puzzle

2011-02-27 Thread Yitzchak Gale
You have written a large software system in Haskell. Wishing to play to Haskell's strength, you have structured your system as a series of composable layers. So you have data types Layer1, Layer2, ... and functions layer2 :: Layer1 - Layer2 layer3 :: Layer2 - Layer3 ... etc. Of course you'll