Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-17 Thread Magicloud Magiclouds
Thank you. Will do.

On Mon, Sep 17, 2012 at 7:14 AM, Antoine Latter  wrote:
> On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe  wrote:
>>
>> On 15/09/2012, at 5:14 AM, Chris Heller wrote:
>>
>>> You might want to have a look at the time-recurrence package: 
>>> http://hackage.haskell.org/package/time-recurrence
>>>
>>> For your simple cases you would do something like:
>>>
>>> Each second:
>>>
>>> starting (UTCTime ...) $ recur secondly
>>>
>>> Each minute:
>>>
>>> starting (UTCTime ...) $ recur minutely
>>
>> Ouch.  Look up "minutely" (my-NEWT-ly) in an English
>> dictionary.  Look up "secondly" while you're there.
>>
>>
>
> You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are:
>
> freq= "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY"
>/ "WEEKLY" / "MONTHLY" / "YEARLY"
>
> Antoine
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-16 Thread Heller Time
Antoine has it right, the language is lifted from the RFC.

Chris Heller
SAS - Advanced Analytics
Teragram Research & Development
phone: 1-617-576-6800 x54237
mobile: 1-617-460-3643
email: hel...@teragram.com

On Sep 16, 2012, at 7:14 PM, Antoine Latter  wrote:

> On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe  wrote:
>> 
>> On 15/09/2012, at 5:14 AM, Chris Heller wrote:
>> 
>>> You might want to have a look at the time-recurrence package: 
>>> http://hackage.haskell.org/package/time-recurrence
>>> 
>>> For your simple cases you would do something like:
>>> 
>>> Each second:
>>> 
>>>starting (UTCTime ...) $ recur secondly
>>> 
>>> Each minute:
>>> 
>>>starting (UTCTime ...) $ recur minutely
>> 
>> Ouch.  Look up "minutely" (my-NEWT-ly) in an English
>> dictionary.  Look up "secondly" while you're there.
>> 
>> 
> 
> You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are:
> 
> freq= "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY"
>   / "WEEKLY" / "MONTHLY" / "YEARLY"
> 
> Antoine

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-16 Thread Antoine Latter
On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe  wrote:
>
> On 15/09/2012, at 5:14 AM, Chris Heller wrote:
>
>> You might want to have a look at the time-recurrence package: 
>> http://hackage.haskell.org/package/time-recurrence
>>
>> For your simple cases you would do something like:
>>
>> Each second:
>>
>> starting (UTCTime ...) $ recur secondly
>>
>> Each minute:
>>
>> starting (UTCTime ...) $ recur minutely
>
> Ouch.  Look up "minutely" (my-NEWT-ly) in an English
> dictionary.  Look up "secondly" while you're there.
>
>

You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are:

freq= "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY"
   / "WEEKLY" / "MONTHLY" / "YEARLY"

Antoine

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-16 Thread Richard O'Keefe

On 15/09/2012, at 5:14 AM, Chris Heller wrote:

> You might want to have a look at the time-recurrence package: 
> http://hackage.haskell.org/package/time-recurrence
> 
> For your simple cases you would do something like:
> 
> Each second:
> 
> starting (UTCTime ...) $ recur secondly
> 
> Each minute:
> 
> starting (UTCTime ...) $ recur minutely

Ouch.  Look up "minutely" (my-NEWT-ly) in an English
dictionary.  Look up "secondly" while you're there.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-14 Thread Magicloud Magiclouds
This is nice. Thanks to all.

On Fri, Sep 14, 2012 at 4:03 PM, Roman Cheplyaka  wrote:
> Consider using the time-lens package.
>
>   import Data.Time.Lens
>   import Data.Lens.Common
>
> List comprehension style:
>
>   [modL seconds (+ fromIntegral n) t | n <- [0..]]
>   [modL minutes (+ n) t | n <- [0..]]
>
> (you need fromIntegral for seconds, because it is of fractional type in
> Data.Time).
>
> iterate style, as suggested by Karl:
>
>   iterate (seconds ^+= 1) t
>   iterate (minutes ^+= 1) t
>
> On Fri, Sep 14, 2012 at 7:29 AM, Magicloud Magiclouds
>  wrote:
>>
>> Hi,
>>   Simple usage, I could make an instance of Enum to UTCTime, so
>> [utcTime..] could work. But that is so stiff. How if sometimes I want
>> to step by 1 min, sometimes I want to step by 1 sec?
>>   So I think some way like [ t | addUTCTime last 60 ] could be nice.
>> But I cannot figure it out
>>   Any idea?
>> --
>> 竹密岂妨流水过
>> 山高哪阻野云飞
>>
>> And for G+, please use magiclouds#gmail.com.
>>
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>



-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-14 Thread Roman Cheplyaka
Consider using the time-lens package.

  import Data.Time.Lens
  import Data.Lens.Common

List comprehension style:

  [modL seconds (+ fromIntegral n) t | n <- [0..]]
  [modL minutes (+ n) t | n <- [0..]]

(you need fromIntegral for seconds, because it is of fractional type in
Data.Time).

iterate style, as suggested by Karl:

  iterate (seconds ^+= 1) t
  iterate (minutes ^+= 1) t

On Fri, Sep 14, 2012 at 7:29 AM, Magicloud Magiclouds <
magicloud.magiclo...@gmail.com> wrote:

> Hi,
>   Simple usage, I could make an instance of Enum to UTCTime, so
> [utcTime..] could work. But that is so stiff. How if sometimes I want
> to step by 1 min, sometimes I want to step by 1 sec?
>   So I think some way like [ t | addUTCTime last 60 ] could be nice.
> But I cannot figure it out
>   Any idea?
> --
> 竹密岂妨流水过
> 山高哪阻野云飞
>
> And for G+, please use magiclouds#gmail.com.
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-13 Thread Karl Voelker
On Thu, Sep 13, 2012 at 10:29 PM, Magicloud Magiclouds <
magicloud.magiclo...@gmail.com> wrote:

> Hi,
>   Simple usage, I could make an instance of Enum to UTCTime, so
> [utcTime..] could work. But that is so stiff. How if sometimes I want
> to step by 1 min, sometimes I want to step by 1 sec?
>   So I think some way like [ t | addUTCTime last 60 ] could be nice.
> But I cannot figure it out
>   Any idea?
>

Try using Prelude.iterate.

-Karl
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-13 Thread Magicloud Magiclouds
Hi,
  Simple usage, I could make an instance of Enum to UTCTime, so
[utcTime..] could work. But that is so stiff. How if sometimes I want
to step by 1 min, sometimes I want to step by 1 sec?
  So I think some way like [ t | addUTCTime last 60 ] could be nice.
But I cannot figure it out
  Any idea?
-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe