[Haskell-cafe] Converting EpochTime to Integer

Bram Neijt bneijt at gmail.com
Wed Sep 16 15:30:07 UTC 2015


Thank you all for your responses!

I've decided to use fromEnum (and I'm going to read up on how that works.)

Greetings,

Bram

On Wed, Sep 16, 2015 at 4:53 PM, David Kraeutmann <kane at kane.cx> wrote:
> I was looking at the wrong EpochTime, whoops.
>
> On 9/15/2015 6:48 PM, David Kraeutmann wrote:
>> EpochTime is an instance of Integral. You can just use toInteger ::
>> Integral a => a -> Integer.
>> On 9/15/2015 6:42 PM, Bram Neijt wrote:
>>> Dear Haskell cafe,
>>>
>>> I want to convert form
>>>
>>> mtime :: System.Posix.Types.EpochTime
>>>
>>> to something aeson can eat without having to define an instance. I
>>> choose Integer.
>>>
>>> My current solution[1] is just using (read . show). I know, ugly, but
>>> the only thing I could get going.
>>>
>>> What is the proper way to convert System.Posix.Types.EpochTime to
>>> Integer or something else aeson will automatically convert without
>>> making a ToJSON instance?
>>>
>>> As a beginner I wonder: is there a general way to go about finding
>>> conversion paths between types?
>>>
>>>
>>> Greetings,
>>>
>>> Bram Neijt
>>>
>>> [1] https://github.com/bneijt/httpmtimeline/blob/master/src/Main.hs#L21
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>>
>>
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list