name:                o-clock
version:             1.0.0
synopsis:            Type-safe time library.
description:         See README.md for details.
homepage:            https://github.com/serokell/o-clock
bug-reports:         https://github.com/serokell/o-clock/issues
license:             MIT
license-file:        LICENSE
author:              @serokell
maintainer:          Serokell <hi@serokell.io>
copyright:           2018 Serokell
category:            Time
build-type:          Simple
stability:           stable
extra-doc-files:     CHANGELOG.md
                   , README.md
                   , README.lhs
cabal-version:       2.0
tested-with:         GHC == 8.0.2
                   , GHC == 8.2.2
                   , GHC == 8.4.3

source-repository head
  type:     git
  location: https://github.com/serokell/o-clock

library
  hs-source-dirs:      src
  exposed-modules:     Time
                         Time.Rational
                         Time.Series
                         Time.Timestamp
                         Time.Units
  ghc-options:         -Wall
  build-depends:       base         >= 4.9  && < 5
                     , ghc-prim     >= 0.5
  default-language:    Haskell2010
  default-extensions:  OverloadedStrings
                       RecordWildCards
                       ScopedTypeVariables
                       TypeApplications
                       TypeFamilies
  if flag(aeson)
    build-depends:     aeson    >= 1.2.4
                     , text
    cpp-options:       -DHAS_aeson
  if flag(hashable)
    build-depends:     hashable >= 1.2.6
    cpp-options:       -DHAS_hashable
  if flag(deepseq)
    build-depends:     deepseq  >= 1.4
    cpp-options:       -DHAS_deepseq
  if flag(serialise)
    build-depends:     serialise >= 0.2
    cpp-options:       -DHAS_serialise

executable play-o-clock
  main-is:             Playground.hs
  build-depends:       o-clock
                     , base     >= 4.9  && < 5
  hs-source-dirs:      examples
  default-language:    Haskell2010
  ghc-options:         -threaded -Wall
                       -fno-warn-orphans

test-suite o-clock-test
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Spec.hs

  other-modules:       Test.Time.Property
                       Test.Time.Timestamp
                       Test.Time.TypeSpec
                       Test.Time.Units

  build-depends:       base            >= 4.9  && < 5
                     , o-clock
                     , hedgehog       ^>= 0.5.1
                     , tasty          ^>= 0.12
                     , tasty-hedgehog ^>= 0.1
                     , tasty-hspec    ^>= 1.1.3
                     , type-spec      ^>= 0.3.0.1

  ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N
  default-language:    Haskell2010
  default-extensions:  OverloadedStrings
                       RecordWildCards

test-suite o-clock-doctest
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Doctest.hs

  build-tool-depends:  doctest:doctest
  build-depends:       base    >= 4.10 && < 5
                     , doctest >= 0.13
                     , Glob    >= 0.9
  ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N
  default-language:    Haskell2010

test-suite readme-test
  type:                exitcode-stdio-1.0
  main-is:             README.lhs

  build-tool-depends:  markdown-unlit:markdown-unlit
  build-depends:       base            >= 4.10  && < 5
                     , o-clock
                     , markdown-unlit ^>= 0.5
  ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N -pgmL markdown-unlit
  default-language:    Haskell2010

benchmark o-clock-benchmark
  type:                exitcode-stdio-1.0
  default-language:    Haskell2010
  ghc-options:         -Wall -O2 -threaded -rtsopts -with-rtsopts=-N
  hs-source-dirs:      benchmark
  main-is:             Main.hs
  build-depends:       base       >= 4.8   && < 5
                     , o-clock
                     , gauge      >= 0.2.1 && < 1
                     , tiempo     >= 0.0.1.1
                     , time-units == 1.0.0
  if !flag(deepseq)
    build-depends:     deepseq    >= 1.4
    cpp-options:       -DNO_deepseq

  default-extensions:  OverloadedStrings
                       RecordWildCards

-- Flags

flag aeson
  description:         Provide instances for @aeson@
  default:             False

flag hashable
  description:         Provide instances for @hashable@
  default:             False

flag deepseq
  description:         Provide instances for @deepseq@
  default:             False

flag serialise
  description:         Provide instances for @serialise@
  default:             False