[Haskell-cafe] Syntax of 'do'
Hi, http://haskell.org/haskellwiki/Keywords says that: - [do is a] syntactic sugar for use with monadic expressions. For example: do { x ; result - y ; foo result } is shorthand for: x y = \result - foo result - I did some tests hiding Prelude. and Prelude.= and applying and = to non-monadic types, and saw that 'do' would not apply to them. So, I would like to add the following to that text: - as long as proper types apply: x :: Prelude.Monad a y :: Prelude.Monad b foo :: b - Prelude.Monad c - Is that correct (Haskell and English)? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntax of 'do'
-XNoImplicitPrelude ? On 29 Aug 2008, at 17:41, Maurí cio wrote: Hi, http://haskell.org/haskellwiki/Keywords says that: - [do is a] syntactic sugar for use with monadic expressions. For example: do { x ; result - y ; foo result } is shorthand for: x y = \result - foo result - I did some tests hiding Prelude. and Prelude.= and applying and = to non-monadic types, and saw that 'do' would not apply to them. So, I would like to add the following to that text: - as long as proper types apply: x :: Prelude.Monad a y :: Prelude.Monad b foo :: b - Prelude.Monad c - Is that correct (Haskell and English)? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntax of 'do'
Hello Mauricio, Friday, August 29, 2008, 5:41:41 PM, you wrote: afaik, this shorthand isn't exact. actually there is more code dealing with fails and this code use Monad operations Hi, http://haskell.org/haskellwiki/Keywords says that: - [do is a] syntactic sugar for use with monadic expressions. For example: do { x ; result - y ; foo result } is shorthand for: x y = \result - foo result - I did some tests hiding Prelude. and Prelude.= and applying and = to non-monadic types, and saw that 'do' would not apply to them. So, I would like to add the following to that text: - as long as proper types apply: x :: Prelude.Monad a y :: Prelude.Monad b foo :: b - Prelude.Monad c - Is that correct (Haskell and English)? Thanks, Mauricio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntax of 'do'
2008/8/29 Maurício [EMAIL PROTECTED]: x :: Prelude.Monad a y :: Prelude.Monad b foo :: b - Prelude.Monad c Monad is not a type, it is a type class, so you probably mean: x :: Monad m = m a y :: Monad m = m b foo :: Monad m = b - m c With the further understanding that all three `m's must be the same. -- -David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntax of 'do'
On Fri, Aug 29, 2008 at 6:41 AM, Maurício [EMAIL PROTECTED] wrote: Hi, http://haskell.org/haskellwiki/Keywords says that: - [do is a] syntactic sugar for use with monadic expressions. For example: do { x ; result - y ; foo result } is shorthand for: x y = \result - foo result - I did some tests hiding Prelude. and Prelude.= and applying and = to non-monadic types, and saw that 'do' would not apply to them. So, I would like to add the following to that text: It sounds like you tried to redefine () and (=) and make 'do' use the new definitions. This is not possible, regardless of what types you give () and (=). If you want to define () and (=), do so for a particular instance of Monad. - as long as proper types apply: x :: Prelude.Monad a y :: Prelude.Monad b foo :: b - Prelude.Monad c - Is that correct (Haskell and English)? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntax of 'do'
2008/8/29 Philip Weaver [EMAIL PROTECTED]: It sounds like you tried to redefine () and (=) and make 'do' use the new definitions. This is not possible, regardless of what types you give () and (=). Watch out for rebindable syntax: http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#rebindable-syntax At first reading, I thought that -XNoImplicitPrelude was required to turn this on. But now I'm not sure: it seems that if you hide Prelude.= and Prelude.return, that ought to be enough to make do notation work with your alternative definitions. I'm not at home, so I can't try this right now. -- -David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntax of 'do'
On Fri, Aug 29, 2008 at 8:50 AM, David House [EMAIL PROTECTED] wrote: 2008/8/29 Philip Weaver [EMAIL PROTECTED]: It sounds like you tried to redefine () and (=) and make 'do' use the new definitions. This is not possible, regardless of what types you give () and (=). Watch out for rebindable syntax: http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#rebindable-syntax Oh, I had no idea! Thanks :). At first reading, I thought that -XNoImplicitPrelude was required to turn this on. But now I'm not sure: it seems that if you hide Prelude.= and Prelude.return, that ought to be enough to make do notation work with your alternative definitions. I'm not at home, so I can't try this right now. -- -David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe