Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Help with Data.Time (Hong Yang)
2. Re: Help with Data.Time (Daniel Fischer)
3. Re: Help with Data.Time (Tim Attwood)
4. RE: examples of Crypto (Kui Ma)
5. Re: examples of Crypto (Michael Snoyman)
6. main (John Moore)
7. Re: main (Keith Sheppard)
----------------------------------------------------------------------
Message: 1
Date: Thu, 1 Oct 2009 17:13:38 -0500
From: Hong Yang <[email protected]>
Subject: [Haskell-beginners] Help with Data.Time
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
I want to calculate the length of time between time ta and time tb.
Time ta is a String looking like "N:NNAM" or "N:NNPM."
I need tb to be 9:30AM on the current date.
I think the flow should be
1) parse ta to utcTimeA :: UTCTime
2) get current date and form tb to utcTimeB :: UTCTime
3) call "diffUTCTime utcTimeA utcTimeB"
So my program looks like as follows in a "do" expression:
let utcTimeA = fromJust (parseTime defaultTimeLocale "%R%P" ta :: Maybe
UTCTime)
currentTime <- getCurrentTime
let day = utctDay currentTime
let utcTimeB = UTCTime day "09:30:00.0000000 UTC"
let timeElapsed = diffUTCTime utcTimeA utcTimeB
There are two difficulties I could not get around:
1) It seems that parseTime returns "Nothing". Why?
2) I knew "09:30:00.0000000 UTC" in the statement of "let utcTimeB ..." is
incorrect, because it is a String instead of expected DiffTime type. After
consulting Data.Time module (it just say "Data DiffTime"), I still cannot
figure out how to get utcTimeB.
Can someone help me?
Thanks,
Hong
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091001/44b4fa9e/attachment-0001.html
------------------------------
Message: 2
Date: Fri, 2 Oct 2009 03:33:34 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Help with Data.Time
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-15"
Am Freitag 02 Oktober 2009 00:13:38 schrieb Hong Yang:
> I want to calculate the length of time between time ta and time tb.
> Time ta is a String looking like "N:NNAM" or "N:NNPM."
> I need tb to be 9:30AM on the current date.
>
> I think the flow should be
> 1) parse ta to utcTimeA :: UTCTime
> 2) get current date and form tb to utcTimeB :: UTCTime
> 3) call "diffUTCTime utcTimeA utcTimeB"
>
> So my program looks like as follows in a "do" expression:
<moved>
> There are two difficulties I could not get around:
> 1) It seems that parseTime returns "Nothing". Why?
parseTime expects two digits for the hours:
Prelude Data.Time System.Locale> parseTime defaultTimeLocale "%R%P" "09:30AM"
::
MaybeUTCTime
Just 1970-01-01 09:30:00 UTC
> 2) I knew "09:30:00.0000000 UTC" in the statement of "let utcTimeB ..." is
> incorrect, because it is a String instead of expected DiffTime type. After
> consulting Data.Time module (it just say "Data DiffTime"), I still cannot
> figure out how to get utcTimeB.
>
> let utcTimeA = fromJust (parseTime defaultTimeLocale "%R%P" ta :: Maybe
> UTCTime)
Note that that will be the time of day on the first of January 1970, probably
not what you
want.
If you want it to have the current day, change the day like below, otherwise
you'd have to
give the date in the string to parse, too
> currentTime <- getCurrentTime
let Just temp = parseTime defaultTimeLocale "%RP" "09:30AM"
utcTimeB = currentTime{ utctDayTime = utctDayTime temp }
-- utcTimeB = temp{ utctDay = utctDay currentTime } is another option
timeElapsed = diffUTCTime utcTimeA utcTimeB
> let day = utctDay currentTime
> let utcTimeB = UTCTime day "09:30:00.0000000 UTC"
> let timeElapsed = diffUTCTime utcTimeA utcTimeB
>
>
> Can someone help me?
>
> Thanks,
>
> Hong
------------------------------
Message: 3
Date: Thu, 1 Oct 2009 21:36:03 -0700
From: "Tim Attwood" <[email protected]>
Subject: [Haskell-beginners] Re: Help with Data.Time
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; format=flowed; charset="ISO-8859-15";
reply-type=original
> Prelude Data.Time System.Locale> parseTime defaultTimeLocale "%R%P"
> "09:30AM" ::
> MaybeUTCTime
> Just 1970-01-01 09:30:00 UTC
Prelude Data.Time System.Locale> parseTime defaultTimeLocale "%R%P"
"09:30AM" ::
Maybe UTCTime
Nothing
I suspect the parser malfunction is an issue with POSIX and Windows.
1970-01-01 00:00 UTC is the POSIX zero time...
------------------------------
Message: 4
Date: Sat, 3 Oct 2009 21:19:18 +0800
From: Kui Ma <[email protected]>
Subject: RE: [Haskell-beginners] examples of Crypto
To: <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
This is exactly what I need. It helped me learn how to use the symmetry
encryption algorithm. Thank you very much!
Regards,
Kui
-----------------------------------------------------------------------------------------------------------------
I use it in clientsession: http://hackage.haskell.org/package/clientsession.
Let me know if I can be of some assistance.
Michael
2009/9/28 Kui Ma <[email protected]>
Hello,
I want some examples to learn the package of Crypto, anyone knows where I can
find them? Thank you in advance!
Regards,
kui
Invite your mail contacts to join your friends list with Windows Live Spaces.
It's easy! Try it!
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
_________________________________________________________________
Windows Live Hotmail: Your friends can get your Facebook updates, right from
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091003/99a2aa9d/attachment-0001.html
------------------------------
Message: 5
Date: Sat, 3 Oct 2009 20:40:46 +0200
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] examples of Crypto
To: Kui Ma <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
No problem, any time ;)
Michael
On Sat, Oct 3, 2009 at 3:19 PM, Kui Ma <[email protected]> wrote:
>
> This is exactly what I need. It helped me learn how to use the symmetry
> encryption algorithm. Thank you very much!
>
> Regards,
> Kui
>
> -----------------------------------------------------------------------------------------------------------------
>
>
> I use it in clientsession:
> http://hackage.haskell.org/package/clientsession. Let me know if I can be
> of some assistance.
>
> Michael
>
> 2009/9/28 Kui Ma <[email protected]>
>
>
> Hello,
>
> I want some examples to learn the package of Crypto, anyone knows where I
> can find them? Thank you in advance!
>
> Regards,
> kui
>
> ------------------------------
> Invite your mail contacts to join your friends list with Windows Live
> Spaces. It's easy! Try
> it!<http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
> ------------------------------
> Windows Live Hotmail: Your friends can get your Facebook updates, right
> from
> Hotmail®.<http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091003/70beb1d3/attachment-0001.html
------------------------------
Message: 6
Date: Sat, 3 Oct 2009 20:07:50 +0100
From: "John Moore" <[email protected]>
Subject: [Haskell-beginners] main
To: <[email protected]>
Message-ID: <6656e51f7bd24292a0296c70f2868...@johnpmoore1>
Content-Type: text/plain; charset="us-ascii"
Hi,
I must be doing something wrong when I run a program it comes up on the
screen as OK module loaded Main
*Main>
But it will not do what I program to do. What do I enter after *main> I
tried putting in the arguments but ot just returns the arguments.
For example:
signum x | x < 0 = -1
| x == 0 = 0
| x > 0 = 1
Enter 5 it returns 5
What have I missed?
Regards
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091003/914ab9c2/attachment-0001.html
------------------------------
Message: 7
Date: Sat, 3 Oct 2009 15:36:32 -0400
From: Keith Sheppard <[email protected]>
Subject: Re: [Haskell-beginners] main
To: John Moore <[email protected]>, [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hello, if you enter ":h" at the prompt it gives all of the available
ghci commands. I think this is the one you're looking for
:main [<arguments> ...] run the main function with the given arguments
-Keith
On Sat, Oct 3, 2009 at 3:07 PM, John Moore <[email protected]> wrote:
> Hi,
> I must be doing something wrong when I run a program it comes up on the
> screen as OK module loaded Main
> *Main>
> But it will not do what I program to do. What do I enter after *main> I
> tried putting in the arguments but ot just returns the arguments.
>
> For example:
>
> signum x | x < 0 = -1
> | x == 0 = 0
> | x > 0 = 1
>
> Enter 5 it returns 5
>
> What have I missed?
>
> Regards
>
> John
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
--
keithsheppard.name
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 16, Issue 1
****************************************