Re: [Haskell-cafe] Either e Monad
Albert Lai wrote: Deokhwan Kim [EMAIL PROTECTED] writes: Where is the Monad instance declaration of Either e? It is in Control.Monad.Error as well. Strange: the doc doesn't state it. Thanks a lot, Albert! I found the declaration in libraries/mtl/Control/Monad/Error.hs of the ghc source distribution: instance (Error e) = Monad (Either e) where return= Right Left l = _ = Left l Right r = k = k r fail msg = Left (strMsg msg) -- Deokhwan Kim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Either e Monad
Dear all, Where is the Monad instance declaration of Either e? From the description of Control.Monad.Error, I deduce that Either e is an instance of Monad. http://haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-Error.html class Monad m = MonadError e m | m - e where ... Error e = MonadError e (Either e) But, I cannot find the Monad instance declaration of Either anywhere. Thanks. -- Deokhwan Kim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Monad laws
What is the practical meaning of monad laws? (M, return, =) is not qualified as a category-theoretical monad, if the following laws are not satisfied: 1. (return x) = f == f x 2. m = return == m 3. (m = f) = g == m (\x - f x = g) But what practical problems can unsatisfying them cause? In other words, I wonder if declaring a instance of the Monad class but not checking it for monad laws may cause any problems, except for not being qualified as a theoretical monad? Cheers, -- Deokhwan Kim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] The values of infinite lists
Are the values of infinite lists _|_ (bottom)? In section 1.3, the Haskell 98 report said as follows: Errors in Haskell are semantically equivalent to _|_. Technically, they are not distinguishable from nontermination, so the language includes no mechanism for detecting or acting upon errors. Therefore, the value of the following infinity is _|_. Right? data Nat = Zero | Succ Nat infinity = Succ infinity What about infinite lists? For example, is the value of [1 ..] also _|_? Thanks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe