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. Re: get date (Luca Ciciriello) 2. Re: Signatures (Ertugrul Soeylemez) 3. Category Theory (Matt Andrew) 4. Re: get date (Brandon S Allbery KF8NH) ---------------------------------------------------------------------- Message: 1 Date: Thu, 24 Jun 2010 11:20:55 +0200 From: Luca Ciciriello <luca_cicirie...@hotmail.com> Subject: Re: [Haskell-beginners] get date To: Ozgur Akgun <ozgurak...@gmail.com> Cc: beginners@haskell.org Message-ID: <blu0-smtp79ff0fc10391336c123a179a...@phx.gbl> Content-Type: text/plain; charset="us-ascii" Ok this solve my problem. I've just missed an IO before String in the type signature. Thanks. Luca. On Jun 24, 2010, at 11:16 AM, Ozgur Akgun wrote: > Then you might want to use something like: > > currentTimeStr :: IO String > currentTimeStr = do ct <- currentTime > return ("File creation date: " ++ show ct ++ " by > MyCompany") > > Or more concisely, > > currentTimeStr :: IO String > currentTimeStr = liftM (\ ct -> "File creation date: " ++ show ct ++ " by > MyCompany" ) currentTime > > My point is, the type of currentTimeStr is IO String, not just String. > Because you are working on an IO value. > > Best, > > PS: If you are not confident with the piece of code I've suggested, please > have a look at the io/monads/do-notation sections of the Real World Haskell. > > > On 24 June 2010 11:17, Luca Ciciriello <luca_cicirie...@hotmail.com> wrote: > Starting from the beginning, my original problem is to create the string: > > "File creation date: " ++ currentSystemDate ++ " by MyCompany" > > to obtain the string > > "File creation date: 2010-06-24 by MyCompany" > > Probably this is really trivial, but I'm a real beginner in Haskell and this > seems to me a big problem. > > Luca. > > On Jun 24, 2010, at 9:59 AM, Ozgur Akgun wrote: > >> On 24 June 2010 10:52, Luca Ciciriello <luca_cicirie...@hotmail.com> wrote: >> Just a question. >> How can I obtain a String from >> >> currentTime :: IO Day >> currentTime = utctDay `fmap` getCurrentTime >> >> Here currentTime returns to me 2010-06-24, but I want "2010-06-24". >> In another worlds I need a function >> >> >> I bet Day has a Show instance (that's why you get 2010-06-24 in ghci I >> suppose) >> Just use that. >> >> >> currentTimeStr :: IO Day -> String >> >> >> Getting out of IO? I would think again. Following might be what you really >> want: >> >> currentTimeStr :: IO Day -> IO String >> >> >> Any Idea? >> >> Luca. >> >> Best, >> Ozgur > > > > > -- > Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20100624/2348323d/attachment-0001.html ------------------------------ Message: 2 Date: Thu, 24 Jun 2010 12:04:45 +0200 From: Ertugrul Soeylemez <e...@ertes.de> Subject: [Haskell-beginners] Re: Signatures To: beginners@haskell.org Message-ID: <20100624120445.72454...@tritium.streitmacht.eu> Content-Type: text/plain; charset=US-ASCII Daniel Fischer <daniel.is.fisc...@web.de> wrote: > On Wednesday 23 June 2010 19:01:21, Colin Paul Adams wrote: > > >>>>> "Patrick" == Patrick LeBoutillier <patrick.leboutill...@gmail.com> > writes: > > >>> So > > >>> > > >>> nightmare :: Offspring ? > > > > If you make > > > > Patrick> sex :: Partner -> IO [STD] > > > > Patrick> then perhaps > > > > Patrick> nightmare :: [STD] > > > > Patrick> becomes more universal... > > > > > > > > What's an STD? > > Sexually transmitted disease Anyway, don't perform IO unsafely. You might regret it. Sex is another form of -- well -- input and output. Here are the types: getWrongWife :: IO BadWife sex :: F___able a => a -> IO (MVar Offspring, Set Disease) Of course you don't get offspring, if you don't "take" it. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ ------------------------------ Message: 3 Date: Thu, 24 Jun 2010 20:33:01 +1000 From: Matt Andrew <mjsa...@gmail.com> Subject: [Haskell-beginners] Category Theory To: beginners@haskell.org Message-ID: <m2fx0cyb36.wl%mjsa...@gmail.com> Content-Type: text/plain; charset=US-ASCII Hi all, I have spend some time over the last couple of days trying to get my head around category theory, in order to understand concepts like monads a little better, in order to understand Haskell a little better =) I have grasped, at least to a degree, the basic concepts of 'category,' 'functor' and 'natural transformation' but I am still fuzzy on a few specifics and had a couple of questions. I'm doing this for self-study and have no one to ask these questions of and so thought I'd ask them here. My first question is this: where are functors understood to 'live,' or exist? They operate on categories, are they therefore understood to exist outside of the categories they operate on? (I understand that functors can form a category themselves, but I'm asking this question in relation to the categories they operate on. Are they inside or outside of them?) In other words when I define a functor in Haskell, are the pair of functions 'fmap,' and whatever unary type constructor is defined along with it, then part of the morphisms of the Haskell category? Or are they outside of the Haskell category (where the Haskell category I've seen defined in the articles I've read is one where its objects are types and its morphisms functions on those types)? This leads me to my next question. It seems that all functors in Haskell (or at least all members of the functor typeclass) are covalent endofunctors. Does this mean that whenever a new functor is defined in Haskell, that the Haskell category (H) grows to accomodate the effects of that functor? In other words, for any covalent endofunctor F : H -> H, do H's morphisms then grow to include F(f) and objects to include F(a), where a is any object in H and f is any morphism in H? I have been working off the assumption that the answer to my last question is 'yes.' The reason for this is natural transformations. Where functors seem to be able to be 'outside' of the categories they operate on (whether they are in fact 'outside' or not is my first question), natural transformations appear to have to be 'inside.' My understanding of the theory is that a natural transformation is a collection of morphisms in the target category of two parallel functors (where such morphisms operate on the functors and meet some specific properties). Surely the only way such a collection of morphisms would make sense would be if the objects they map to/from (i.e. the structures imposed by the two functors) were part of that category also? I hope these questions make sense. I really appreciate anyone who takes to time to read this! Matt ------------------------------ Message: 4 Date: Thu, 24 Jun 2010 10:08:50 -0400 From: Brandon S Allbery KF8NH <allb...@ece.cmu.edu> Subject: Re: [Haskell-beginners] get date To: beginners@haskell.org Message-ID: <4c2366f2.3060...@ece.cmu.edu> Content-Type: text/plain; charset=UTF-8 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 6/24/10 03:52 , Luca Ciciriello wrote: > Just a question. > How can I obtain a String from > > currentTime :: IO Day > currentTime = utctDay `fmap` getCurrentTime > > Here currentTime returns to me 2010-06-24, but I want "2010-06-24". > In another worlds I need a function > > currentTimeStr :: IO Day -> String You can't escape from IO, but you can lift a formatter into IO. Formatters are in Data.Time.Format; look at the documentation for your system's strftime() function to see how it works. - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwjZuIACgkQIn7hlCsL25UwpgCfRuhCW5sB9G8Ud9Ci3JUZbVTt vAIAn3CFOoX9Q4etASv3ggC8KFxm94W6 =ZUFJ -----END PGP SIGNATURE----- ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 24, Issue 33 *****************************************