[Haskell-beginners] Time interval calculation

legajid legajid at free.fr
Sat Mar 13 17:09:48 EST 2010


I tried

!t1f <- gettime

and i got an error message :
premier.hs:92:1: Illegal bang-pattern (use -XBangPatterns)
Failed, modules loaded: none.


t1f <- !gettime gives :
premier.hs:92:8: parse error on input `!'
Failed, modules loaded: none.



Daniel Fischer a écrit :
> Am Samstag 13 März 2010 22:02:41 schrieb legajid:
>   
>> Sorry Daniel,
>> i've seen your answer just after posting my reply.
>>     
>
> Thought so. Happens to me often enough :)
>
>   
>> But i can't write !t1f <- gettime,
>>     
>
> You can, and it's much like
>
> let !t1 = ...
>
> for the pure calculation, it evaluates t1f to the outermost constructor. If 
> deeper evaluation is needed, like for pure values, you have to use the 
> appropriate forcing strategy.
>
>     !a <- mx
>
> is less important for IO than for other monads, though, since IO imposes a 
> fair amount of sequencing. In particular, the sequencing of IO makes
>
>     !t1f <- gettime
>
> superfluous, since all that could be delayed in gettime is the 
> transformation of the timestamp retrieved from the system clock to the 
> ClockTime datatype, the timestamp is retrieved at the exact point in the 
> IO-sequence.
>
>   
>> nor t1f <- !gettime;
>>     
>
> I'm not sure whether you can write that, but it wouldn't be what you want 
> anyway. If that's legal BangPattern syntax, it says "evaluate gettime to 
> the outermost constructor", which is far less than we need to evaluate 
> gettime to bind its result to a name.
>
>   
>> because it's an
>> IO ? Your method is a good help form me.
>>
>> Thanks,
>> Didier
>>     
>
>
>   


More information about the Beginners mailing list