{-# OPTIONS_GHC -Wno-orphans #-}

module IsomorphismClass.Relations.DiffTimeAndPico where

import Data.Time
import IsomorphismClass.Classes
import IsomorphismClass.Prelude

instance IsomorphicTo DiffTime Pico where
  to :: Pico -> DiffTime
to = Integer -> DiffTime
picosecondsToDiffTime (Integer -> DiffTime) -> (Pico -> Integer) -> Pico -> DiffTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Pico -> Integer
picoToInteger
    where
      picoToInteger :: Pico -> Integer
      picoToInteger :: Pico -> Integer
picoToInteger (MkFixed Integer
p) = Integer
p

instance IsomorphicTo Pico DiffTime where
  to :: DiffTime -> Pico
to = Integer -> Pico
forall k (a :: k). Integer -> Fixed a
MkFixed (Integer -> Pico) -> (DiffTime -> Integer) -> DiffTime -> Pico
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DiffTime -> Integer
diffTimeToPicoseconds