Haskell type containing no non-_|_ values?
Hello, probably a trivial question: Is there a type in Haskell that contains only the undefined value _|_? The polymorphic type (forall a. a) has this property, but it seems it cannot be used, e.g., in a tuple:
x :: (Int,(forall a. a)) x = (3,undefined)
leads to errors both in Hugs and GHC. I guess I can help myself out using newtype:
newtype T = T (forall a. a)
x :: (Int,T) x = (3,undefined)
but would like to do without. Is there a way? Thanks, Janis. -- Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de
Hi Janis! On Fri, 26 Mar 2004, Janis Voigtlaender wrote:
probably a trivial question: Is there a type in Haskell that contains only the undefined value _|_?
The polymorphic type (forall a. a) has this property, but it seems it cannot be used, e.g., in a tuple:
x :: (Int,(forall a. a)) x = (3,undefined)
leads to errors both in Hugs and GHC.
I guess I can help myself out using newtype:
newtype T = T (forall a. a)
x :: (Int,T) x = (3,undefined)
but would like to do without. Is there a way?
Yep, there is a way. newtype Void = Void Void This type only have the following value: void = Void void Now, someone on this mailing list will surely think that this looks different from undefined. But remember that the constructors in newtype definitions are only there as a hint for the typechecker, they have no operational meaning. So void is really undefined. Cheers, /Josef
On Fri, Mar 26, 2004 at 01:43:25PM +0100, Janis Voigtlaender wrote:
Hello,
probably a trivial question: Is there a type in Haskell that contains only the undefined value _|_?
I guess I can help myself out using newtype:
newtype T = T (forall a. a)
This is not Haskell 98.
but would like to do without. Is there a way?
With newtype and conforming to Haskell 98: newtype B = B B Without newtype but using GHC extenstions: data B I don't know if you can have both 'no newtype' and 'haskell 98' satisfied. Best regards, Tom -- .signature: Too many levels of symbolic links
Tomasz Zielonka wrote:
On Fri, Mar 26, 2004 at 01:56:04PM +0100, Tomasz Zielonka wrote:
I don't know if you can have both 'no newtype' and 'haskell 98' satisfied.
Ross Paterson provided a solution using data.
I didn't yet see that solution since I receive Haskell mails in digest mode. Anyway, "Haskell 98" is not a must. What I would want is a type that doesn't need additional declarations, be it newtype or data. "forall a. a" has this property, a pre-defined type would also have this property. BTW, what is the reason for not allowing (forall a. a) as part of a tuple? Ciao, Janis. -- Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de
participants (4)
-
Janis Voigtlaender -
Josef Svenningsson -
Ross Paterson -
Tomasz Zielonka