Is Cons in the Haskell Module Library

Good morning, I'm going through Graham Hutton's link on Category Theory [and yes I understand that you needn't study CT in order to use Haskell] and he uses Cons. I realize that Cons may be a synonym for ':'. But can someone tell me how to search the Haskell Library to find the module containing Cons? Thank you and Merry Christmas

Hello Patrick,
But can someone tell me how to search the Haskell Library to find the module containing Cons?
I (sadly) know nothing about Category Theory, so I probably am missing something, but when I'm looking for the module where a function or data type belongs to, I usually use Hoogle: http://www.haskell.org/hoogle/ (there's a hoogle command-line tool too). Is it what you're after? On a side note I tend to assimilate lisp's cons to Haskell's (:) too. I wouldn't mind if someone corrects this view of mine in case it's not correct :) Regards, Nadir

On Sun, Dec 22, 2013 at 12:23:42PM -0500, Patrick Lynch wrote:
Good morning, I'm going through Graham Hutton's link on Category Theory [and yes I understand that you needn't study CT in order to use Haskell] and he uses Cons. I realize that Cons may be a synonym for ':'. But can someone tell me how to search the Haskell Library to find the module containing Cons? Thank you and Merry Christmas
Cons is (:) and is defined in GHC.Types. λ> :i (:) data [] a = ... | a : [a] -- Defined in `GHC.Types' infixr 5 : You could also try hoogle. http://www.haskell.org/hoogle/?hoogle=cons -- Vikraman

On Sun, Dec 22, 2013 at 12:23 PM, Patrick Lynch
Good morning, I'm going through Graham Hutton's link on Category Theory [and yes I understand that you needn't study CT in order to use Haskell] and he uses Cons. I realize that Cons may be a synonym for ':'. But can someone tell me how to search the Haskell Library to find the module containing Cons?
The usual point of Cons is that it's instructive to reconstruct the list type from first principles. You would never do this in a real program, since it's exactly the same as the built-in list type --- except that it doesn't come with all the predefined list stuff, so it's easier for you to build it yourself without interfering with (or being interfered with by!) the standard library. It also doesn't come with the convenient syntactic sugar. And even if for some reason you did need to restrict lists that way in a real program, you would probably use a newtype instead so that you can still use the standard list operations and syntax after unwrapping. data List a = Nil | Cons a (List a) data [] a = [] | (:) a ([] a) -- the builtin list type, for comparison -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Sun, Dec 22, 2013 at 12:23:42PM -0500, Patrick Lynch wrote:
Good morning, I'm going through Graham Hutton's link on Category Theory [and yes I understand that you needn't study CT in order to use Haskell] and he uses Cons. I realize that Cons may be a synonym for ':'. But can someone tell me how to search the Haskell Library to find the module containing Cons? Thank you and Merry Christmas
Are you asking how to find the definition of (:) in Haskell? (It is special built-in syntax.) Or are you asking how to find out what Graham Hutton means by 'Cons'? In the latter case, you will have to tell us exactly where in his notes to look, because out of context it is impossible to tell. -Brent

On Sun, Dec 22, 2013 at 03:38:42PM -0500, Brent Yorgey wrote:
On Sun, Dec 22, 2013 at 12:23:42PM -0500, Patrick Lynch wrote:
Good morning, I'm going through Graham Hutton's link on Category Theory [and yes I understand that you needn't study CT in order to use Haskell] and he uses Cons. I realize that Cons may be a synonym for ':'. But can someone tell me how to search the Haskell Library to find the module containing Cons? Thank you and Merry Christmas
Are you asking how to find the definition of (:) in Haskell? (It is special built-in syntax.) Or are you asking how to find out what Graham Hutton means by 'Cons'? In the latter case, you will have to tell us exactly where in his notes to look, because out of context it is impossible to tell.
Probably this one, page 4. http://www.cs.nott.ac.uk/~gmh/cat2.pdf -- Vikraman
participants (5)
-
Brandon Allbery
-
Brent Yorgey
-
Nadir Sampaoli
-
Patrick Lynch
-
Vikraman