Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented instances of NominalDiffTime missing #33

Open
adambaker opened this issue Apr 15, 2015 · 5 comments
Open

Documented instances of NominalDiffTime missing #33

adambaker opened this issue Apr 15, 2015 · 5 comments
Assignees

Comments

@adambaker
Copy link

In particular, NominalDiffTime is missning (at least) Fractional and Num instances:

*Data.Thyme> 2::NominalDiffTime

<interactive>:3:1:
    No instance for (Num NominalDiffTime) arising from the literal `2'
    In the expression: 2 :: NominalDiffTime
    In an equation for `it': it = 2 :: NominalDiffTime

*Data.Thyme> 2.5::NominalDiffTime

<interactive>:4:1:
    No instance for (Fractional NominalDiffTime)
      arising from the literal `2.5'
    In the expression: 2.5 :: NominalDiffTime
    In an equation for `it': it = 2.5 :: NominalDiffTime

The hackage docs say NominalDiffTime has Fractional and Num instance.

I'm running this on Ubuntu 14.04, and I've tried it on MacOSX Yosemite and seen the same results.

$ cabal list thyme
* thyme
    Synopsis: A faster time library
    Default available version: 0.3.5.5
    Installed versions: 0.3.5.5
    Homepage: https://github.com/liyang/thyme
    License:  BSD3

I plan to work around this with fromSeconds and toSeconds for now.

@liyang
Copy link
Member

liyang commented Apr 15, 2015

The hackage docs say NominalDiffTime has Fractional and Num instance.

You'll get those instances by explicitly importing Data.Thyme.Time. I'll leave this ticket open until I get around to adding a word or two to the documentation along those lines.

I plan to work around this with fromSeconds and toSeconds for now.

Yes, please do. Because the result of NominalDiffTime multiplied/divided by NominalDiffTime is definitely not a NominalDiffTime.

PS: to avoid ambiguous types for literals, use fromSeconds'.

@liyang liyang self-assigned this Apr 15, 2015
@adambaker
Copy link
Author

I'm realizing the correct thing to do is use (^/) from Data.VectorSpace.

One reason I prefer thyme over time is that it's built using many more of these abstractions.

@liyang
Copy link
Member

liyang commented Apr 18, 2015

Ah, so you're scaling a time difference. Yes, use (^/) or even (*^) or (^*). :)

@jasonzoladz
Copy link

Please add this to the docs. Just lost 1.5 hours of my life. :)

@liyang
Copy link
Member

liyang commented Mar 30, 2016

@jasonzoladz At the top of Data.Thyme.Clock, it says:

Num, Real, Fractional and RealFrac instances for DiffTime and NominalDiffTime are only available by importing Data.Thyme.Time. In their stead are instances of AdditiveGroup, HasBasis and VectorSpace, with Scalar DiffTime ≡ Scalar NominalDiffTime ≡ Rational.

I'll try to make it more obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants