Re: [Haskell-cafe] Re: Monads and Functions sequence and sequence_

2010-10-30 Thread Ben Millwood
The actual, entire, complete definitions of sequence and sequence_ are (or at least, could be): sequence [] = return [] sequence (m:ms) = do x - m xs - sequence ms return (x:xs) -- or, equivalently: sequence' = foldr (liftM2 (:)) (return []) sequence_ [] = return () sequence_

[Haskell-cafe] Re: Monads and Functions sequence and sequence_

2010-10-29 Thread Bardur Arantsson
On 2010-10-30 07:07, Mark Spezzano wrote: Hi, Can somebody please explain exactly how the monad functions sequence and sequence_ are meant to work? I have almost every Haskell textbook, but there's surprisingly little information in them about the two functions. From what I can gather,

Re: [Haskell-cafe] Re: Monads and Functions sequence and sequence_

2010-10-29 Thread Mark Spezzano
Not exactly. If you use the type with Maybe Int like so: sequence [Just 1, Nothing, Just 2] then the result is Nothing. Whereas sequence [Just 1, Just 2, Just 3] gives Just [1, 2, 3] Why? I assume there's special implementations of sequence and sequence_ depending on the type of monad used.

Re: [Haskell-cafe] Re: Monads and Functions sequence and sequence_

2010-10-29 Thread Ivan Lazar Miljenovic
On 30 October 2010 16:30, Mark Spezzano mark.spezz...@chariot.net.au wrote: Not exactly. If you use the type with Maybe Int like so: sequence [Just 1, Nothing, Just 2] then the result is Nothing. Whereas sequence [Just 1, Just 2, Just 3] gives Just [1, 2, 3] Why? I assume there's

Re: [Haskell-cafe] Re: Monads and Functions sequence and sequence_

2010-10-29 Thread Daniel Peebles
That is a result of the implementation of the specific Monad instance, and that does depend on the type, as you say (but it isn't determined for sequence(_) specifically). Nothing = f = Nothing Just x = f = f x is why a Nothing pollutes the sequenced lists of Maybes. If Maybe is a Monad

Re: [Haskell-cafe] Re: Monads and Functions sequence and sequence_

2010-10-29 Thread Sebastian Fischer
On Oct 30, 2010, at 2:30 PM, Mark Spezzano wrote: If you use the type with Maybe Int like so: sequence [Just 1, Nothing, Just 2] then the result is Nothing. Whereas sequence [Just 1, Just 2, Just 3] gives Just [1, 2, 3] Try do x - Just 1 y - Nothing z - Just 2

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-15 Thread Apfelmus, Heinrich
Ertugrul Soeylemez wrote: [...] Thank you for your reply, I think I can refine my thoughts. And make them much longer... ;) The elegance I have in mind comes from abstraction, that is when a type takes a meaning on its own, independent of its implementation. Let's take the example of vector

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-15 Thread Ertugrul Soeylemez
Apfelmus, Heinrich apfel...@quantentunnel.de wrote: [...] but this is very different from using a particular monad like the state monad and hoping that using it somehow gives an insight into the problem domain. You're right, mostly. However, there are a lot of problems, where you cannot

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread ChrisK
Henning Thielemann wrote: I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and other writing functions. This is a clear indicator, that the Monad instance is artificial and was only chosen because of the 'do' notation. I completely

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Ross Paterson
On Tue, Jan 13, 2009 at 10:16:32AM +, ChrisK wrote: Henning Thielemann wrote: I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and other writing functions. This is a clear indicator, that the Monad instance is artificial and was only

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Tim Newsham
I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and other writing functions. This is a clear indicator, that the Monad instance is artificial and was only chosen because of the 'do' notation. Maybe that was the initial reason, but I've

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Luke Palmer
On Tue, Jan 13, 2009 at 11:21 AM, Tim Newsham news...@lava.net wrote: I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and other writing functions. This is a clear indicator, that the Monad instance is artificial and was only chosen

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Dan Doel
On Tuesday 13 January 2009 5:51:09 pm Luke Palmer wrote: On Tue, Jan 13, 2009 at 11:21 AM, Tim Newsham news...@lava.net wrote: I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and other writing functions. This is a clear indicator,

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Luke Palmer
On Tue, Jan 13, 2009 at 5:19 PM, Dan Doel dan.d...@gmail.com wrote: On Tuesday 13 January 2009 5:51:09 pm Luke Palmer wrote: On Tue, Jan 13, 2009 at 11:21 AM, Tim Newsham news...@lava.net wrote: I have seen several libraries where all functions of a monad have the monadic result (),

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Dan Doel
On Tuesday 13 January 2009 7:27:10 pm Luke Palmer wrote: When GHC starts optimizing (Writer Builder) as well as it optimizes PutM, then that will be a cogent argument. Until then, one might argue that it misses the whole point of Put. Well it can still serve as an optimization over

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Duncan Coutts
On Tue, 2009-01-13 at 19:19 -0500, Dan Doel wrote: On Tuesday 13 January 2009 5:51:09 pm Luke Palmer wrote: On Tue, Jan 13, 2009 at 11:21 AM, Tim Newsham news...@lava.net wrote: I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Ross Paterson
On Tue, Jan 13, 2009 at 07:44:17PM -0500, Dan Doel wrote: On Tuesday 13 January 2009 7:27:10 pm Luke Palmer wrote: Surely PutM and Writer Put have almost the same performance?! (I am worried if not -- if not, can you give an indication why?) The underlying monoid is Builder. The point of

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread Duncan Coutts
On Tue, 2009-01-13 at 19:44 -0500, Dan Doel wrote: On Tuesday 13 January 2009 7:27:10 pm Luke Palmer wrote: When GHC starts optimizing (Writer Builder) as well as it optimizes PutM, then that will be a cogent argument. Until then, one might argue that it misses the whole point of Put.

Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-12 Thread Henning Thielemann
Ertugrul Soeylemez schrieb: Apfelmus, Heinrich apfel...@quantentunnel.de wrote: The insistence on avoiding monads by experienced Haskellers, in particular on avoiding the IO monad, is motivated by the quest for elegance. The IO and other monads make it easy to fall back to imperative

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-11 Thread Ertugrul Soeylemez
Apfelmus, Heinrich apfel...@quantentunnel.de wrote: Ertugrul Soeylemez wrote: Let me tell you that usually 90% of my code is monadic and there is really nothing wrong with that. I use especially State monads and StateT transformers very often, because they are convenient and are just a

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-11 Thread Ertugrul Soeylemez
Ertugrul Soeylemez e...@ertes.de wrote: Personally I prefer this: somethingWithRandomsM :: (Monad m, Random a) = m a - Something a Of course, there is something missing here: somethingWithRandomsM :: (Monad m, Random a) = m a - m (Something a) Sorry. Greets, Ertugrul. -- nightmare

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Jason Dusek
It is really too bad we can not define the operators _ ^_^ _ These are significant from an internationalization standpoint; and they'd make the language so much more competitive vis-a-vis LOLCode. -- Jason Dusek 2009/1/10 Brandon S. Allbery KF8NH allb...@ece.cmu.edu: On 2009

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread minh thu
I always thought that instead of having two classes of characters, one for variable (and function) names and the other for operators, only the first charater of the identifier could mean it's one or the others, so *vec or +point would be valid operator names and thus _ too. And C++ could be a Data

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Martijn van Steenbergen
minh thu wrote: I always thought that instead of having two classes of characters, one for variable (and function) names and the other for operators, only the first charater of the identifier could mean it's one or the others, so *vec or +point would be valid operator names and thus _ too. And

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread minh thu
2009/1/11 Martijn van Steenbergen mart...@van.steenbergen.nl: minh thu wrote: I always thought that instead of having two classes of characters, one for variable (and function) names and the other for operators, only the first charater of the identifier could mean it's one or the others, so

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Miguel Mitrofanov
Indeed but what's wrong in writing x + y (with additional spaces) ? Having the possiblity to write for instance +blah instead of inventing things such as $* is neat in my opinion (in code or for typesetting)... I believe it was Bulat Ziganshin who once proposed parsing x + y*z + t

Re[2]: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Bulat Ziganshin
Hello Miguel, Sunday, January 11, 2009, 7:06:54 PM, you wrote: I believe it was Bulat Ziganshin who once proposed parsing x + y*z + t as x + (y * z) + t and x + y * z + t as (x + y) * (z + t) x+y * z+t should be here -- Best regards, Bulat

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Lennart Augustsson
Agda has made the choice that you can have (almost) any sequence of characters in identifiers. It works fine, but forces you to use white space (which I do anyway). -- Lennart On Sun, Jan 11, 2009 at 4:28 PM, Martijn van Steenbergen mart...@van.steenbergen.nl wrote: minh thu wrote: I

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Martijn van Steenbergen
Lennart Augustsson wrote: Agda has made the choice that you can have (almost) any sequence of characters in identifiers. It works fine, but forces you to use white space (which I do anyway). No _'s though, which is exactly what Jason was after. :-) Still, Agda rocks. Martijn.

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-11 Thread Alberto G. Corona
As a physicist, I think that programming, like any design in general, is all about making as little use of brain resources as possible at the time of solving problems and to transmit the solution to others. This is the reason why it is pervasive in all kinds of engineering the concepts of

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-10 Thread Peter Verswyvelen
Related to this issue, I have a question here. I might be wrong, but it seems to me that some Haskellers don't like writing monads (with do notation) or arrows (with proc sugar) because of the fact they have to abandon the typical applicative syntax, which is so close to the beautiful lambda

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-10 Thread Ryan Ingram
My issue is that there seem to be many cases where the syntax extension does *almost* what I want, but not quite. And there isn't any method to extend it, so you are left with two choices: (1) Go back to unsugared syntax (2) Hack your technique into the constraints of the existing syntax

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-10 Thread Peter Verswyvelen
For example, which of these is easier to read? f,g :: Int - [Int] h1 :: Int - [Int] h1 x = do fx - f x gx - g x return (fx + gx) h2 :: Int - [Int] h2 x = (+) $ f x * g x h3 :: Int - [Int] h3 x = f x + g x -- not legal, of course, but wouldn't it be nice if it was?

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-10 Thread Brandon S. Allbery KF8NH
On 2009 Jan 10, at 15:19, Peter Verswyvelen wrote: h3 x = f x ^(+)^ g x Is that an operator or Batman? (yes, I know, 3 operators) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and

Re: [Haskell-cafe] Re: Monads aren't evil

2009-01-10 Thread Andrew Wagner
Holy concatenated operators, Batman! Is that an operator or Batman? (yes, I know, 3 operators) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie

[Haskell-cafe] Re: Monads aren't evil

2009-01-08 Thread Neal Alexander
Ertugrul Soeylemez wrote: Hello fellow Haskellers, When I read questions from Haskell beginners, it somehow seems like they try to avoid monads and view them as a last resort, if there is no easy non-monadic way. I'm really sure that the cause for this is that most tutorials deal with monads

[Haskell-cafe] re: monads with take-out options

2008-11-25 Thread Greg Meredith
John, You write: Yes, you are describing 'co-monads'. Good catch, but actually, that's too weak. i'm requesting something that is both a monad and a co-monad. That makes it something like a bi-algebra, or a Hopf algebra. This, however, is not the full story. i'm looking for a reference to the

Re: [Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-17 Thread Yitzchak Gale
Derek Elkins wrote: There is another very closely related adjunction that is less often mentioned. ((-)-C)^op -| (-)-C or a - b - C ~ b - a - C This gives rise to the monad, M a = (a - C) - C this is also exactly the comonad it gives rise to (in the op category which ends up being the

Re: [Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-17 Thread David Menendez
On Dec 17, 2007 4:34 AM, Yitzchak Gale [EMAIL PROTECTED] wrote: Derek Elkins wrote: There is another very closely related adjunction that is less often mentioned. ((-)-C)^op -| (-)-C or a - b - C ~ b - a - C This gives rise to the monad, M a = (a - C) - C this is also exactly

Re: [Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-17 Thread Derek Elkins
On Mon, 2007-12-17 at 09:58 -0500, David Menendez wrote: On Dec 17, 2007 4:34 AM, Yitzchak Gale [EMAIL PROTECTED] wrote: Derek Elkins wrote: There is another very closely related adjunction that is less often mentioned. ((-)-C)^op -|

[Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-16 Thread apfelmus
Dan Weston wrote: newtype O f g a = O (f (g a)) -- Functor composition: f `O` g instance (Functor f, Functor g) = Functor (O f g) where ... instance Adjunction f g = Monad (O g f) where ... instance Adjunction f g = Comonad (O f g) where ... class (Functor f, Functor g)

Re: [Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-16 Thread Derek Elkins
On Sun, 2007-12-16 at 13:49 +0100, apfelmus wrote: Dan Weston wrote: newtype O f g a = O (f (g a)) -- Functor composition: f `O` g instance (Functor f, Functor g) = Functor (O f g) where ... instance Adjunction f g = Monad (O g f) where ... instance Adjunction f g =

[Haskell-cafe] Re: Monads

2007-12-03 Thread Ben Franksen
PR Stanley wrote: Does the list consider http://en.wikibooks.org/w/index.php?title=Haskell/Understanding_monadsoldid=933545 a reliable tutorial on monads and, if not, could you recommend an onlien alternative please? I strongly recommend the original papers by Philip Wadler, especially this

[Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-02 Thread Greg Meredith
Arie, Thanks for your thoughtful reply. Comments in-lined. Best wishes, --greg Date: Thu, 2 Aug 2007 03:06:51 +0200 (CEST) From: Arie Peterson [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] Re: monads and groups -- instead of loops To: haskell-cafe@haskell.org Message-ID: [EMAIL PROTECTED

Re: [Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-02 Thread Wouter Swierstra
On 1 Aug 2007, at 21:23, Greg Meredith wrote: But, along these lines i have been wondering for a while... the monad laws present an alternative categorification of monoid. At least it's alternative to monoidoid. In the spirit of this thought, does anyone know of an expansion of the monad

[Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-01 Thread Greg Meredith
Haskellians, But, along these lines i have been wondering for a while... the monad laws present an alternative categorification of monoid. At least it's alternative to monoidoid. In the spirit of this thought, does anyone know of an expansion of the monad axioms to include an inverse action?

Re: [Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-01 Thread Arie Peterson
Math alert: mild category theory. Greg Meredith wrote: But, along these lines i have been wondering for a while... the monad laws present an alternative categorification of monoid. At least it's alternative to monoidoid. I wouldn't call monads categorifications of monoids, strictly speaking.

[Haskell-cafe] Re: Monads and constraint satisfaction problems (CSP)

2007-05-31 Thread Greg Meredith
Brandon, Jeremy, et al, Thanks for the pointers. The paper by OlegK, et al, articulates exactly the structure i was noticing, except that i was coming at it from the other end. i was noticing that a wide range of these CSP-style problems could be decomposed into a trivial monad (e.g., list,

Re: [Haskell-cafe] Re: Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-26 Thread Wolfgang Jeltsch
Am Samstag, 26. November 2005 03:56 schrieb Geoffrey Alan Washburn: [lots of code] It's interesting to note how verbose Java is in comparison to Haskell, at least, concerning this monad stuff. Best wishes, Wolfgang ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-26 Thread Geoffrey Alan Washburn
Wolfgang Jeltsch wrote: Am Samstag, 26. November 2005 03:56 schrieb Geoffrey Alan Washburn: [lots of code] It's interesting to note how verbose Java is in comparison to Haskell, at least, concerning this monad stuff. I'd agree. However, my original point was that my version that uses

[Haskell-cafe] Re: Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-25 Thread Geoffrey Alan Washburn
Shae Matijs Erisson wrote: Gregory Woodhouse [EMAIL PROTECTED] writes: My knowledge of functional programming is pretty much limited to Haskell, Scheme, and a smattering of Common Lisp. Are there languages other than Haskell that explicitly use monads? How about not so explicitly? Java