Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-22 Thread Janis Voigtlaender
Peter Hercek wrote: But Haskell with Control.Exception extension has more values of all types since they can be thrown and later caught and investigated at that place. Maybe the last sentence of section 2.1 (_|_ Bottom) of Haskell/Denotational semantics should be clarified better.

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-22 Thread Janis Voigtlaender
Henning Thielemann wrote: On Sat, 22 Nov 2008, Janis Voigtlaender wrote: Definitely. And that surfaces even in quite innocently looking programs and statements about them. The introductory example of the following technical report may be amusing in that respect:

[Haskell-cafe] Re: Type question in instance of a class

2008-11-18 Thread Maurí­cio
(...) One way to code this would be to use functional dependencies: class MyClass r s | r - s where function :: r - s One additional problem is that I (believe I) need that my class takes just one type FDs with just one type parameter are called ATs :) (FDs = functional

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-18 Thread Reiner Pope
ATs are Associated Types, aka Type Families. They can be found in the GHC 6.10 manual here: http://haskell.org/ghc/docs/6.10.1/html/users_guide/type-families.html As a starting point, you might want to try something like: class Complex c where type RealType c realPart :: c - RealType c

[Haskell-cafe] Re: Type question in instance of a class

2008-11-18 Thread Peter Hercek
David Menendez wrote: On Sun, Nov 16, 2008 at 7:09 PM, Luke Palmer [EMAIL PROTECTED] wrote: On Sun, Nov 16, 2008 at 5:06 PM, Peter Hercek [EMAIL PROTECTED] wrote: ... and the only value the function can return is bottom. Is there any type system which would have more than one value which

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-18 Thread J. Garrett Morris
On Tue, Nov 18, 2008 at 1:38 AM, Reiner Pope [EMAIL PROTECTED] wrote: ATs are Associated Types, aka Type Families. They can be found in the GHC 6.10 manual here: http://haskell.org/ghc/docs/6.10.1/html/users_guide/type-families.html As a starting point, you might want to try something like:

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-18 Thread Jonathan Cast
On Tue, 2008-11-18 at 19:05 +0100, Peter Hercek wrote: David Menendez wrote: On Sun, Nov 16, 2008 at 7:09 PM, Luke Palmer [EMAIL PROTECTED] wrote: On Sun, Nov 16, 2008 at 5:06 PM, Peter Hercek [EMAIL PROTECTED] wrote: ... and the only value the function can return is bottom. Is there any

[Haskell-cafe] Re: Type question in instance of a class

2008-11-17 Thread Maurí­cio
Why is this wrong? (...) (...) One way to code this would be to use functional dependencies: class MyClass r s | r - s where function :: r - s data MyData u = MyData u instance MyClass (MyData v) v where function (MyData a) = a One additional problem is that I (believe I) need that my

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-17 Thread Bulat Ziganshin
Hello Maurí­cio, Monday, November 17, 2008, 9:38:06 PM, you wrote: (...) One way to code this would be to use functional dependencies: class MyClass r s | r - s where function :: r - s One additional problem is that I (believe I) need that my class takes just one type FDs with just

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-17 Thread J. Garrett Morris
On Mon, Nov 17, 2008 at 10:38 AM, Maurí­cio [EMAIL PROTECTED] wrote: newtype ComplexWithDouble = ComplexWithDouble (ComplexNumber Double) deriving ... Perhaps you want something like: class Complex r c | c - r where makeComplex :: r - r - c realPart :: c - r imagPart

[Haskell-cafe] Re: Type question in instance of a class

2008-11-17 Thread Maurí­cio
Perhaps you want something like: class Complex r c | c - r where makeComplex :: r - r - c realPart :: c - r imagPart :: c - r data ComplexNumber t = CN t t instance Complex t (ComplexNumber t) where makeComplex = CN realPart (CN r _) = r imagPart

[Haskell-cafe] Re: Type question in instance of a class

2008-11-16 Thread Peter Hercek
Bulat Ziganshin wrote: Hello J., Monday, November 17, 2008, 12:56:02 AM, you wrote: class MyClass r where function :: r - s As Bulat said, your type signature is equivalent to: function :: forall r s. r - s only function :: forall s. r - s (r is fixed in class header) ... and the

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-16 Thread Luke Palmer
On Sun, Nov 16, 2008 at 5:06 PM, Peter Hercek [EMAIL PROTECTED] wrote: ... and the only value the function can return is bottom. Is there any type system which would have more than one value which inhabits all types? Well something like lazy C# might; i.e. every value has a _|_

Re: [Haskell-cafe] Re: Type question in instance of a class

2008-11-16 Thread David Menendez
On Sun, Nov 16, 2008 at 7:09 PM, Luke Palmer [EMAIL PROTECTED] wrote: On Sun, Nov 16, 2008 at 5:06 PM, Peter Hercek [EMAIL PROTECTED] wrote: ... and the only value the function can return is bottom. Is there any type system which would have more than one value which inhabits all types? Well