[Haskell-cafe] Pattern matching

2007-01-15 Thread Stefan Aeschbacher
Hi I sometimes have a function definition similar to this: myFunction x@(Constructor1 _ _ _ _ _ _) = ... myFunction x@(Constructor2 _ _ _ _ _ _ _ _) = ... which in my eyes is not very elegant and easy to type. Is there an easier way to switch on the different constructors of a type

Re: [Haskell-cafe] Pattern matching

2007-01-15 Thread Stefan O'Rear
On Mon, Jan 15, 2007 at 10:09:10AM +0100, Stefan Aeschbacher wrote: Hi I sometimes have a function definition similar to this: myFunction x@(Constructor1 _ _ _ _ _ _) = ... myFunction x@(Constructor2 _ _ _ _ _ _ _ _) = ... myFunction [EMAIL PROTECTED] = ... myFunction [EMAIL PROTECTED] =

Re: [Haskell-cafe] Pattern matching

2007-01-15 Thread Neil Mitchell
Hi Stefan, myFunction x@(Constructor1 _*) = ... myFunction x@(Constructor2 _*) = ... myFunction x@(Constructor1 {}) = myFunction x@(Constructor2 {}) = myFunction2 (Constructor1 _* a _*) = ... could be possible as long as the pattern is non-ambiguous (in this case, only one variable with

Re: [Haskell-cafe] Pattern matching

2007-01-15 Thread Stefan Aeschbacher
2007/1/15, Stefan O'Rear [EMAIL PROTECTED]: On Mon, Jan 15, 2007 at 10:09:10AM +0100, Stefan Aeschbacher wrote: Hi I sometimes have a function definition similar to this: myFunction x@(Constructor1 _ _ _ _ _ _) = ... myFunction x@(Constructor2 _ _ _ _ _ _ _ _) = ... myFunction [EMAIL

Re: [Haskell-cafe] Literate Haskell source files. How do I

2007-01-15 Thread Eric Kow
Hi, On 30/12/06, Michael T. Richter [EMAIL PROTECTED] wrote: Are there any tools which I can use to render .lhs files readable? I'm fine with having them converted into documented source (i.e. source code embedded in documentation) or as pure Haskell source (but without the huge

Re: [Haskell-cafe] Higher kinds (and impredicativity?)

2007-01-15 Thread Jim Apple
On 1/15/07, Doaitse Swierstra [EMAIL PROTECTED] wrote: Values that live as elements in data have to be data themselves, and thus have to be of a type that has kind *. But the example I give doesn't have a value of kind * - * living in data. The constructor is nullary, only the parameter to the

Re: [Haskell-cafe] Higher kinds (and impredicativity?)

2007-01-15 Thread Jim Apple
On 1/15/07, Jim Apple [EMAIL PROTECTED] wrote: data OK' (x :: *) where OK' :: OK' x type Fine' = OK' Maybe type Evil' = OK' (forall (f :: *) . f) Correction: that Maybe should obviously be something of kind *, like Bool. Jim ___ Haskell-Cafe

Re: [Haskell-cafe] Redefining superclass default methods in a subclass

2007-01-15 Thread Brian Hulley
Meng Wang wrote: Hi Brian, Thank you for starting the thread. We (Martin Sulzmann and me) proposed a type class extension which allows modular extension of superclasses (a complement of subclass extension). The idea has been shown to be particularly useful in (but not limited to) encodings of

[Haskell-cafe] What does the withProcessHandle_ function do?

2007-01-15 Thread John Ky
I want to learn how to use FFI with Win32, so I'm looking through the GHC source code. I encountered the function terminateProcess :: ProcessHandle - IO () terminateProcess ph = do withProcessHandle_ ph $ \p_ - case p_ of ClosedHandle _ - return p_ OpenHandle h - do

[Haskell-cafe] Re: Higher kinds (and impredicativity?)

2007-01-15 Thread Chung-chieh Shan
Jim Apple [EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: C, x : k1 |- y : * --- C |- (\forall x : k1 . y) : * I'd expect C, x : k1 |- y : k2 --- C |- (\forall x : k1 . y) : k2 Is there a foundational or

Re: [Haskell-cafe] Re: Higher kinds (and impredicativity?)

2007-01-15 Thread Jim Apple
On 1/15/07, Chung-chieh Shan [EMAIL PROTECTED] wrote: I consider it a foundational reason. You seem to want (forall (f :: * - *) . f) to have kind * - *. But that means that I should be able to apply it to a type, say Int, to get a type (forall (f :: * - *) . f) Int. What

[Haskell-cafe] Newbie: Project: Missionary and Cannibal in Haskell

2007-01-15 Thread thapaps
I am very new to haskell. my project is to solve Missionary and Cannibal this is what I have been given : 1. 3 Missionary and 3 Cannibal . 2. 1 boat. 3. Max passengers=2. 4. RULE: at any given time number of cannibal cannot exceed number of missionary 5. I need to move all the

[Haskell-cafe] Re: Higher kinds (and impredicativity?)

2007-01-15 Thread Chung-chieh Shan
Jim Apple [EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: (forall (f :: * - *) . f) Int. What values inhabit this type? The same ones that inhabit (forall (f :: * - *) . f Int); that is, none (or _|_). I don't see the uninhabitability of a type as

Re: [Haskell-cafe] Newbie: Project: Missionary and Cannibal in Haskell

2007-01-15 Thread Henk-Jan van Tuyl
This might not be the solution you are looking for, but a mathematical approach to solving this problem is explained by Edsge W. Dijkstra in a video at http://www.cs.utexas.edu/users/EWD/video-audio/video-audio.html Click on The Power of Counting Arguments Met vriendelijke groet,