Is there a way to hide an existing data type so that I can use my own version?
Hi Folks, For learning purposes, I created an "Either" data type: data Either a b = Left a | Right b deriving (Show) However, when I try to use Left (or Right), I get an error message saying that it is ambiguous whether I am using Prelude.Left or Main.Left So I tried hiding Prelude.Either like so: import Prelude hiding Either But that produced an error. Is there a way to hide the existing Either data type so that I can use my own version? /Roger
On Tue, 31 Jul 2012 13:08:38 +0200, Costello, Roger L. <costello@mitre.org> wrote:
import Prelude hiding Either
That should be: import Prelude hiding (Either) Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --
Ah, excellent. Thanks Henk-Jan. This works perfectly: -------------------------------------------------------- import Prelude hiding (Either, Left, Right) data Either a b = Left a | Right b deriving (Show) -------------------------------------------------------- /Roger -----Original Message----- From: Henk-Jan van Tuyl [mailto:hjgtuyl@chello.nl] Sent: Tuesday, July 31, 2012 7:19 AM To: beginners@haskell.org; Costello, Roger L. Subject: Re: [Haskell-beginners] Is there a way to hide an existing data type so that I can use my own version? On Tue, 31 Jul 2012 13:08:38 +0200, Costello, Roger L. <costello@mitre.org> wrote:
import Prelude hiding Either
That should be: import Prelude hiding (Either) Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --
participants (2)
-
Costello, Roger L. -
Henk-Jan van Tuyl