[Haskell-beginners] Beginners Digest, Vol 56, Issue 22
Patrick Lynch
kmandpjlynch at verizon.net
Wed Feb 13 16:27:12 CET 2013
Good morning Brent.
Thank you for your recomendation.
I went to Amazon and checked the Table of Contents on the book you
mentioned...
It costs $90 and its not really what I'm looking for.
I'm going to approach this from a different direction. It is:
1. I'm looking for a the Haskell definition of the category Hask...If you
can help me out here, I'd appreciate it.
2. Functor, Monoid and Monad are all classes in Haskell...I'm going to
try to determine how they are related to Hask and to each other.
To do this, I'll review my two favorite Haskell books: "Real World
Haskell" by O'Sullivan etal and "Learn You a Haskell for Great Good!..." by
Lipovaca.
I'll review Functor, Monoid and Monad in these two books and do the
associated exercises [though Lipovaca book does not contain exercises].
Unfortunately, neither book contains an explanation of Hask [and all
of the other Haskell books in my library also do not define Hask].
3. If you know of an online course pertaining to Haskell and CT, I'd
appreciate hearing about it.
4. I may, "shudder", even consider going back to university and pick up
two or three courses in regard to this.
I'll let you know how I make out - I'm heading off on a long, long journey
Good day,
Patrick
----- Original Message -----
From: <beginners-request at haskell.org>
To: <beginners at haskell.org>
Sent: Tuesday, February 12, 2013 4:43 PM
Subject: Beginners Digest, Vol 56, Issue 22
> Send Beginners mailing list submissions to
> beginners at 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-request at haskell.org
>
> You can reach the person managing the list at
> beginners-owner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
> 1. Re: Beginners Digest, Vol 56, Issue 20 (Brent Yorgey)
> 2. Re: f . g or f g or f $ g? (Martin Drautzburg)
> 3. Re: f . g or f g or f $ g? (Emanuel Koczwara)
> 4. Parsec simple question (Sean Cormican)
> 5. Re: f . g or f g or f $ g? (Patrick Mylund Nielsen)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 12 Feb 2013 14:14:15 -0500
> From: Brent Yorgey <byorgey at seas.upenn.edu>
> Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 20
> To: beginners at haskell.org
> Message-ID: <20130212191415.GA5182 at seas.upenn.edu>
> Content-Type: text/plain; charset=utf-8
>
> Hi Patrick,
>
> I would highly recommend
>
> Jeremy Gibbons, "Calculating Functional Programs". In Roland
> Backhouse? Roy Crole and Jeremy Gibbons, editors, Algebraic and
> Coalgebraic Methods in the Mathematics of Program
> Construction. Vol. 2297 of Lecture Notes in Computer Science. Pages
> 148?203. Springer?Verlag. 2002.
>
> http://www.cs.ox.ac.uk/publications/publication2360-abstract.html
>
>>From what you've said it sounds like this is exactly what you're
> looking for.
>
> -Brent
>
> On Tue, Feb 12, 2013 at 10:02:14AM -0500, Patrick Lynch wrote:
>> Good morning,
>>
>> I've actually have 6 books in my library. They are:
>> 1. "Algebra Third Edition" by MacLane and Birkhoff
>> [I couldn't get anything out of this book]
>> 2. "Categories for the Working Mathemetician - Second Edition" by Mac
>> Lane
>> [I could get through the first chapter and then gave up]
>> 3. "Conceptual Mathematics - A first introduction to categories" by
>> Lawvere and Schanuel
>> [The first chapter was understandable but the following chapters
>> were completely undecipherable]
>> 4. " Basic Category Theory for Computer Scientists" by Pierce
>> [I could get through all three chapters but couldn't do the
>> exercies - and could not see how CT applies to Haskell {especially,
>> Monoids, Monads and Functors}]
>> 5. "Categories and Computer Science" by Walters
>> [This one made me cry]
>> 6. "Category Theory" by Awodey
>> [Again, I could only get through the first chapter]
>>
>> I tried viewing the videos by Eugenia Cheng - but I just couldn't
>> follow her presentation.
>> I also viewed another video entitled Hasket and CT - but it was given
>> by a mathematican and I couldn't follow this fellow - I'll have to
>> get the link for this.
>> I finally viewed a video by Brian Beckman in regard to FP [eg: F# and
>> Haskell - and mentions C# as a comparison non-FP language],
>> specifically, in regard to Monoids and it was great - however, he
>> didn't go into CT - but he did recommend that the viewer pursue it.
>>
>> I'm really not interested in all of the categories in the world...I
>> specifically am interested in how CT applies to Hask, Monoids, Monads
>> and Functors.
>> All of the Haskell authors that I've read have 'ducked' the CT issue
>> - mentioning that it is not necessary to understand Haskell. I often
>> was left with the thought: are they correct or do they simply not
>> understand CT.
>> If you know of a Computer Scientist [and, please, not a
>> Mathematician] who has written in regard to Haskell and CT, please
>> let me know.
>>
>> Hopefully, there is a reference that is available that will help me -
>> if not, I plan on revisting my Haskell books ["Learn You a Haskell
>> for Great Good!..." by Lipovaca and "Real World Haskell" by
>> O'Sullivan, etal] and focus in on Functors, Monoids, Monads and Hask.
>> I'll also view Brian Beckman's video again and see if I can really
>> follow his example.
>>
>> Thank you
>>
>>
>> ----- Original Message ----- From: <beginners-request at haskell.org>
>> To: <beginners at haskell.org>
>> Sent: Tuesday, February 12, 2013 6:00 AM
>> Subject: Beginners Digest, Vol 56, Issue 20
>>
>>
>> >Send Beginners mailing list submissions to
>> >beginners at 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-request at haskell.org
>> >
>> >You can reach the person managing the list at
>> >beginners-owner at haskell.org
>> >
>> >When replying, please edit your Subject line so it is more specific
>> >than "Re: Contents of Beginners digest..."
>> >
>> >
>> >Today's Topics:
>> >
>> > 1. Re: Haskell and Category Theory (Rustom Mody)
>> > 2. Re: Haskell and Category Theory (Joe Fredette)
>> > 3. Re: Effective use of nested Monads (David Hinkes)
>> >
>> >
>> >----------------------------------------------------------------------
>> >
>> >Message: 1
>> >Date: Mon, 11 Feb 2013 19:01:51 +0530
>> >From: Rustom Mody <rustompmody at 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 at haskell.org>
>> >Message-ID:
>> ><CAJ+Teoc=Yn9aWi-7OnOcLPPiywZ+rv__wiEjhTGdVD_0bP_qDg at mail.gmail.com>
>> >Content-Type: text/plain; charset="iso-8859-1"
>> >
>> >On Mon, Feb 11, 2013 at 10:37 AM, Brent Yorgey
>> ><byorgey at seas.upenn.edu>wrote:
>> >
>> >>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
>> >>
>> >
>> >Well Brent is not going to say it I guess so someone needs to:
>> >Typeclassopedia http://www.haskell.org/haskellwiki/Typeclassopedia
>> >is required reading
>> >-------------- next part --------------
>> >An HTML attachment was scrubbed...
>> >URL:
>> ><http://www.haskell.org/pipermail/beginners/attachments/20130211/b8a154b7/attachment-0001.htm>
>> >
>> >------------------------------
>> >
>> >Message: 2
>> >Date: Mon, 11 Feb 2013 08:47:37 -0500
>> >From: Joe Fredette <jfredett at 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 at haskell.org>
>> >Message-ID: <E437EA88-0456-4669-BDDC-FEECE93FD165 at gmail.com>
>> >Content-Type: text/plain; charset="iso-8859-1"
>> >
>> >
>> >While we await a reply, I will say that I found Benjamin Pierce's
>> >"Basic Category Theory for Computer Scientists" pretty readable,
>> >but will also readily admit my understanding of CT is not
>> >particularly deep or great. There are also some videos on youtube,
>> >particularly by [error792](1) which are worth watching, though they
>> >approach from a more math-oriented perspective (the video-author is
>> >a Mathematics Grad Student).
>> >
>> >One thing that helped me a lot was learning a bit about
>> >Combinatorial Species -- I come from a math background, so having
>> >something firmly abstract to grab onto wrt examples of CT in use
>> >was (and is) useful, Brent has a [nice suite of posts](2) on the
>> >matter, and I'm sure will have some book/paper recommendations, I
>> >linked to just one of the posts on his blog, I'm sure you can
>> >navigate to the others.
>> >
>> >The trick, I think, to learning CT is to realize it's a lot like
>> >Set theory -- there's a lot of abstract nonsense and definition
>> >shuffling (which error792's videos, iirc, note as "Soft Theorems"),
>> >and very little (immediate) connection to reality/more concrete
>> >tools. However, CT provides a framework of understanding which acts
>> >kind of like a highway-of-abstraction. When I can say, "A
>> >combinatorial species _is_ an endofunctor on the category of Sets
>> >and their Bijections", I necessarily know that if I can translate
>> >that category into another thing, then I can use my knowledge of
>> >species to inform my knowledge of that thing.
>> >
>> >I'm probably telling this story wrong in some way, perhaps (if we
>> >don't mind a bit of thread hijacking) someone can improve my
>> >understanding of CT by correcting my likely and inevitable
>> >mistakes.
>> >
>> >/Joe
>> >
>> >
>> >(1) http://www.youtube.com/user/error792
>> >
>> >(2)
>> >http://byorgey.wordpress.com/2012/11/20/combinatorial-species-definition/
>> >
>> >
>> >>
>> >>
>> >>On Mon, Feb 11, 2013 at 10:37 AM, Brent Yorgey
>> >><byorgey at seas.upenn.edu> wrote:
>> >>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
>> >>
>> >>Well Brent is not going to say it I guess so someone needs to:
>> >>Typeclassopedia http://www.haskell.org/haskellwiki/Typeclassopedia
>> >>is required reading
>> >>_______________________________________________
>> >>Beginners mailing list
>> >>Beginners at haskell.org
>> >>http://www.haskell.org/mailman/listinfo/beginners
>> >
>> >-------------- next part --------------
>> >An HTML attachment was scrubbed...
>> >URL:
>> ><http://www.haskell.org/pipermail/beginners/attachments/20130211/7d75e152/attachment-0001.htm>
>> >
>> >------------------------------
>> >
>> >Message: 3
>> >Date: Mon, 11 Feb 2013 10:30:56 -0800
>> >From: David Hinkes <david.hinkes at 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 at haskell.org>
>> >Message-ID:
>> ><CA+_CxFPpwmW9X6WJ8b6JSA8=EJwaFhE+gOQZTiOJcfcz9+7mTg at mail.gmail.com>
>> >Content-Type: text/plain; charset="utf-8"
>> >
>> >On Sun, Feb 10, 2013 at 9:17 PM, Brent Yorgey
>> ><byorgey at seas.upenn.edu>wrote:
>> >
>> >>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
>> >
>> >
>> >Thanks Brent, I'll try to re-organize around the transforms.
>> >-------------- next part --------------
>> >An HTML attachment was scrubbed...
>> >URL:
>> ><http://www.haskell.org/pipermail/beginners/attachments/20130211/7c6272bc/attachment-0001.htm>
>> >
>> >------------------------------
>> >
>> >_______________________________________________
>> >Beginners mailing list
>> >Beginners at haskell.org
>> >http://www.haskell.org/mailman/listinfo/beginners
>> >
>> >
>> >End of Beginners Digest, Vol 56, Issue 20
>> >*****************************************
>> >
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 12 Feb 2013 22:09:21 +0100
> From: Martin Drautzburg <Martin.Drautzburg at web.de>
> Subject: Re: [Haskell-beginners] f . g or f g or f $ g?
> To: beginners at haskell.org
> Message-ID: <201302122209.21252.Martin.Drautzburg at web.de>
> Content-Type: Text/Plain; charset="iso-8859-15"
>
> On Friday, 1. February 2013 23:02:39 Ertugrul S?ylemez wrote:
>
>> (f . g) x = f (g x)
>
>
> so (f . g) x = f $ g x
>
> right?
>
> That looks like the two are pretty interchangeable. When would I prefer
> one
> over the other?
>
>
> --
> Martin
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 12 Feb 2013 22:23:50 +0100
> From: Emanuel Koczwara <poczta at emanuelkoczwara.pl>
> Subject: Re: [Haskell-beginners] f . g or f g or f $ g?
> To: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <beginners at haskell.org>
> Message-ID: <1360704230.6251.5.camel at emanuel-Dell-System-Vostro-3750>
> Content-Type: text/plain; charset="UTF-8"
>
> Hi,
>
> Dnia 2013-02-12, wto o godzinie 22:09 +0100, Martin Drautzburg pisze:
>> On Friday, 1. February 2013 23:02:39 Ertugrul S?ylemez wrote:
>>
>> > (f . g) x = f (g x)
>>
>>
>> so (f . g) x = f $ g x
>>
>> right?
>>
>> That looks like the two are pretty interchangeable. When would I prefer
>> one
>> over the other?
>>
>>
>
> ($) has lower precedence (it was introduced for that reason I belive).
>
> Prelude> :info ($)
> ($) :: (a -> b) -> a -> b -- Defined in GHC.Base
> infixr 0 $
>
> Please take a look at:
> http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Prelude.html#v:-36-
>
>>From the docs:
>
> "Application operator. This operator is redundant, since ordinary
> application (f x) means the same as (f $ x). However, $ has low,
> right-associative binding precedence, so it sometimes allows parentheses
> to be omitted..."
>
> Emanuel
>
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 12 Feb 2013 21:38:52 +0000
> From: Sean Cormican <seancormican1 at gmail.com>
> Subject: [Haskell-beginners] Parsec simple question
> To: beginners at haskell.org
> Message-ID:
> <CAF6xeQcrhAcJ_dBf0d51dyRRdG5aHFist8i-skYD+uYwH7yxVg at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I'm having the following issue but I have no idea what to do about it,
> clearly I'm missing something.
>
> integer = P.integer lexer
> identifier = P.identifier lexer
>
> data Expression = ID String
> | Num Integer
> deriving (Show)
>
> name :: Expression
> name = ID "string"
>
> number :: Expression
> number = Num 123
>
> whileParser :: Parser Expression
> whileParser = whiteSpace >> expr8
>
> expr8 :: Parser Expression
> expr8 = name
> <|> number
>
> The error I'm getting is the following:
>
> Couldn't match expected type `Text.Parsec.Prim.ParsecT
> String ()
> Data.Functor.Identity.Identity Expression'
> with actual type `Expression'
> In the first argument of `(<|>)', namely `name'
> In the expression: name <|> number
> In an equation for `expr8': expr8 = name <|> number
> Failed, modules loaded: none.
>
> Also there is an issue where i have the following code changed:
> name = ID "string"
> to
> name = ID identifier
>
> number = Num 123
> to
> number = Num integer
>
> which gives me two further errors regarding:
> Couldn't match expected type `String'
> with actual type `Text.Parsec.Prim.ParsecT
> String ()
> Data.Functor.Identity.Identity String'
>
> and
>
> Couldn't match expected type `Integer'
> with actual type `Text.Parsec.Prim.ParsecT
> String ()
> Data.Functor.Identity.Identity Integer'
>
> Now I am sure this is something silly but thanks for any help!
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://www.haskell.org/pipermail/beginners/attachments/20130212/9ac63501/attachment-0001.htm>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 12 Feb 2013 22:43:37 +0100
> From: Patrick Mylund Nielsen <haskell at patrickmylund.com>
> Subject: Re: [Haskell-beginners] f . g or f g or f $ g?
> To: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <beginners at haskell.org>
> Message-ID:
> <CAEw2jfx13HnB737N9X646hsAg=w4X9nsoVp4-OY5Nij0yDPT8w at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Exactly. It is a convenience operator that lets you do:
>
> f x $ g y $ h z
>
> instead of
>
> f x (g y (h z))
>
>
> As for whether you should write:
>
> foo = f . g
>
> or
>
> foo x = f $ g x
>
> ..go with whichever looks clearest and nicest to you. In most cases where
> you are just taking one argument and applying some functions to it, it's
> nice to omit the x. But in more complex cases, it may make your code
> harder
> to read and modify. See http://www.haskell.org/haskellwiki/Pointfree (and
> Problems with "pointless" style.)
>
> I personally always use pointfree where I would've required a lambda
> expression, e.g.:
>
> f (g . h) y
>
> instead of
>
> f (\x -> g $ h x) y
>
>
>
>
> On Tue, Feb 12, 2013 at 10:23 PM, Emanuel Koczwara <
> poczta at emanuelkoczwara.pl> wrote:
>
>> Hi,
>>
>> Dnia 2013-02-12, wto o godzinie 22:09 +0100, Martin Drautzburg pisze:
>> > On Friday, 1. February 2013 23:02:39 Ertugrul S?ylemez wrote:
>> >
>> > > (f . g) x = f (g x)
>> >
>> >
>> > so (f . g) x = f $ g x
>> >
>> > right?
>> >
>> > That looks like the two are pretty interchangeable. When would I prefer
>> one
>> > over the other?
>> >
>> >
>>
>> ($) has lower precedence (it was introduced for that reason I belive).
>>
>> Prelude> :info ($)
>> ($) :: (a -> b) -> a -> b -- Defined in GHC.Base
>> infixr 0 $
>>
>> Please take a look at:
>>
>> http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Prelude.html#v:-36-
>>
>> From the docs:
>>
>> "Application operator. This operator is redundant, since ordinary
>> application (f x) means the same as (f $ x). However, $ has low,
>> right-associative binding precedence, so it sometimes allows parentheses
>> to be omitted..."
>>
>> Emanuel
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://www.haskell.org/pipermail/beginners/attachments/20130212/7c8f8d83/attachment.htm>
>
> ------------------------------
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
> End of Beginners Digest, Vol 56, Issue 22
> *****************************************
>
More information about the Beginners
mailing list