Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Haskell and Category Theory (Patrick Lynch) 2. Re: Haskell and Category Theory (KC) 3. Re: Haskell and Category Theory (amin...@gmail.com) 4. Re: Haskell and Category Theory (KC) 5. Effective use of nested Monads (David Hinkes) 6. Re: Effective use of nested Monads (Ozgur Akgun) 7. Re: Haskell and Category Theory (Brent Yorgey) 8. Re: Effective use of nested Monads (Brent Yorgey) ---------------------------------------------------------------------- Message: 1 Date: Sun, 10 Feb 2013 12:44:11 -0500 From: "Patrick Lynch" <kmandpjly...@verizon.net> Subject: [Haskell-beginners] Haskell and Category Theory To: <beginners@haskell.org> Message-ID: <B3165B70B11F41C185B9F06B6C6E3A46@UserPC> Content-Type: text/plain; charset="iso-8859-1" Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that can be understood by mere mortals. I was trained as an Electrical Engineer, so my math is quite good, but I just don't get Category Theory from these books. If anyone can recomment a book on Category Theory and Haskell, written by a Computer Scientest [no more Mathematicians for me], I welcome it. Thanks, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130210/8f36a6de/attachment-0001.htm> ------------------------------ Message: 2 Date: Sun, 10 Feb 2013 09:58:18 -0800 From: KC <kc1...@gmail.com> Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Message-ID: <CAMLKXy=+RJFBh5w3CAGYF6tKgzxuf43Jnib59axxaHN9Aks=s...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Category Theory turns function like entities (e.g. procedures - functions with side effects) into functions so that they can be composed like mathematical functions. On Sun, Feb 10, 2013 at 9:44 AM, Patrick Lynch <kmandpjly...@verizon.net> wrote: > Good morning, > I've tried to read 5 books on Category Theory and finally have admitted > defeat. > What I'm looking for is simply a book that is geared to Haskell and Category > that can be understood by mere mortals. > I was trained as an Electrical Engineer, so my math is quite good, but I > just don't get Category Theory from these books. > If anyone can recomment a book on Category Theory and Haskell, written by a > Computer Scientest [no more Mathematicians for me], I welcome it. > Thanks, > Patrick > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- -- Regards, KC ------------------------------ Message: 3 Date: Sun, 10 Feb 2013 13:49:28 -0500 From: amin...@gmail.com Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Cc: "<beginners@haskell.org>" <beginners@haskell.org> Message-ID: <4722d1d6-fc2c-4712-aa62-86b6469bb...@gmail.com> Content-Type: text/plain; charset="us-ascii" I'm a fan of Basic Category Theory for Computer Scientists, by Benjamin Pierce. I can't say it had an immediate payoff for learning Haskell, but it's been helpful longer-term. Tom On Feb 10, 2013, at 12:44 PM, "Patrick Lynch" <kmandpjly...@verizon.net> wrote: > Good morning, > I've tried to read 5 books on Category Theory and finally have admitted > defeat. > What I'm looking for is simply a book that is geared to Haskell and Category > that can be understood by mere mortals. > I was trained as an Electrical Engineer, so my math is quite good, but I just > don't get Category Theory from these books. > If anyone can recomment a book on Category Theory and Haskell, written by a > Computer Scientest [no more Mathematicians for me], I welcome it. > Thanks, > Patrick > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130210/be484d35/attachment-0001.htm> ------------------------------ Message: 4 Date: Sun, 10 Feb 2013 11:46:42 -0800 From: KC <kc1...@gmail.com> Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Message-ID: <CAMLKXykDrm2td4Z=bbb7o67gp0kb+t9nvfpke3dnr3aweti...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 >From "Steps in Scala - An Introduction to Obejct-Functional Programming". Christos K. K. Loverdos and Apostolos Syropoulos, 2010. Section 3.13 pages 163,164 Monads are mathematical structures that were introduced in homological algebra and later they were introduced in category theory. Eugenio Moggi [53] was probably the first researcher who used monads in structuring semantic descriptions of features such as state and exceptions. Philip Wadler [76] established a connection between list comprehensions and monads that led to a generalization of list comprehensions to an arbitrary monad. This feature was employed to express concisely in pure functional programming languages programs that handle exceptions, parse text files, etc. Although it is not necessary to have a solid background in category theory in order to understand the various ideas described in the rest of this section, still we believe it is better to be familiar with some basic notion of category theory. In this section we will introduce the reader to these ideas. Readers who are either familiar with category theory or simply do not want to bother with these mathematical notions, can safely skip this section and ignore all future references to categories. Categories in a nutshell Categories were first introduced by Samuel Eilenberg and Saunders Mac Lane. In a nutshell, a category can be viewed as a mathematical universe. There are many categories and each of them consists of entities, which have the same nature, and ways to pass from one entity to another. Also, there are ways to pass from one category to another. In addition, it is possible to transform these ways from one category to another while preserving their internal structure. A functor is away to go from one category to another that preserves the categorical structure of its domain. There is a lot more. On Sun, Feb 10, 2013 at 9:44 AM, Patrick Lynch <kmandpjly...@verizon.net> wrote: > Good morning, > I've tried to read 5 books on Category Theory and finally have admitted > defeat. > What I'm looking for is simply a book that is geared to Haskell and Category > that can be understood by mere mortals. > I was trained as an Electrical Engineer, so my math is quite good, but I > just don't get Category Theory from these books. > If anyone can recomment a book on Category Theory and Haskell, written by a > Computer Scientest [no more Mathematicians for me], I welcome it. > Thanks, > Patrick > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- -- Regards, KC ------------------------------ Message: 5 Date: Sun, 10 Feb 2013 14:53:18 -0800 From: David Hinkes <david.hin...@gmail.com> Subject: [Haskell-beginners] Effective use of nested Monads To: Haskell Beginners <beginners@haskell.org> Message-ID: <CA+_CxFPSsrygsJCX1g07VkNPT-TaNa3r=0hxabanwr2tlrf...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi haskell-beginners, I'm starting to come to the idea of exposing a Monad as a means of controlling an API. So, I've started creating my own Monad data types based on classical monads. However, I'm running into a problem regarding creating monad definitions when using nested Monads. For example: newtype Example m o = Example { runExample :: State Int (m o) } Is there a clean way to make Example a monad? instance Monad m => Monad (Example m) where -- return is easy return = Example . return . return -- bind is hard. -- f :: o -> Example m p -- a :: Example m o a >>= f = ... My intuition tells me that this should be simple, I should just use the State's bind operation, but I can't seem to make it work. Any advise would be great. Thanks, Dave -- David Hinkes -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130210/9e66d97e/attachment-0001.htm> ------------------------------ Message: 6 Date: Sun, 10 Feb 2013 22:59:48 +0000 From: Ozgur Akgun <ozgurak...@gmail.com> Subject: Re: [Haskell-beginners] Effective use of nested Monads To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Message-ID: <CALzazPCzJKntnWCF7UN_Mp2WoO=s037gqmesejr6r5emtyt...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" See http://hackage.haskell.org/trac/haskell-prime/wiki/NewtypeDeriving HTH, Ozgur -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130210/52c4d150/attachment-0001.htm> ------------------------------ Message: 7 Date: Mon, 11 Feb 2013 00:07:46 -0500 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] Haskell and Category Theory To: beginners@haskell.org Message-ID: <20130211050746.ga30...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Sun, Feb 10, 2013 at 12:44:11PM -0500, Patrick Lynch wrote: > Good morning, > I've tried to read 5 books on Category Theory and finally have admitted > defeat. > What I'm looking for is simply a book that is geared to Haskell and Category > that can be understood by mere mortals. > I was trained as an Electrical Engineer, so my math is quite good, but I just > don't get Category Theory from these books. > If anyone can recomment a book on Category Theory and Haskell, written by a > Computer Scientest [no more Mathematicians for me], I welcome it. > Thanks, > Patrick Can you tell us which books you've tried to read? -Brent ------------------------------ Message: 8 Date: Mon, 11 Feb 2013 00:17:46 -0500 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] Effective use of nested Monads To: beginners@haskell.org Message-ID: <20130211051745.gb30...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Sun, Feb 10, 2013 at 02:53:18PM -0800, David Hinkes wrote: > Hi haskell-beginners, > > I'm starting to come to the idea of exposing a Monad as a means of > controlling an API. So, I've started creating my own Monad data types > based on classical monads. However, I'm running into a problem regarding > creating monad definitions when using nested Monads. > > For example: > > newtype Example m o = Example { > runExample :: State Int (m o) > } > > Is there a clean way to make Example a monad? Actually, there isn't! This is one way in which monads turn out to be *too* powerful: they don't compose very well. If m and n are monads, then their composition (that is, a type like newtype Composed a = Composed (m (n a))) is *not* necessarily a monad! So "nesting" monads in this way is usually not a good idea. What you want are called "monad transformers", which give you a way to "compose" certain monads (though it's more complicated than just nesting them). You can do your Example type something like this: newtype Example m o = Example { runExample :: StateT Int m o } where StateT is the State monad transformer, defined in the 'transformers' package (and also exported from the 'mtl' package). I refer you to the typeclassopedia for more information and links to further reading: http://www.haskell.org/haskellwiki/Typeclassopedia#Monad_transformers -Brent ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 19 *****************************************