{- |
Module      :  Camfort.Specification.Units.Parser.Types
Description :  Defines the representation of unit specifications resulting from parsing.
Copyright   :  (c) 2017, Dominic Orchard, Andrew Rice, Mistral Contrastin, Matthew Danish
License     :  Apache-2.0

Maintainer  :  dom.orchard@gmail.com
Stability   :  experimental
-}

{-# LANGUAGE DeriveDataTypeable #-}

module Camfort.Specification.Units.Parser.Types
  ( UnitStatement(..)
  , UnitOfMeasure(..)
  , UnitPower(..)
  ) where

import Data.Data (Data)
import Data.List (intercalate)

data UnitStatement =
   UnitAssignment (Maybe [String]) UnitOfMeasure
 | UnitAlias String UnitOfMeasure
  deriving (UnitStatement -> UnitStatement -> Bool
(UnitStatement -> UnitStatement -> Bool)
-> (UnitStatement -> UnitStatement -> Bool) -> Eq UnitStatement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnitStatement -> UnitStatement -> Bool
$c/= :: UnitStatement -> UnitStatement -> Bool
== :: UnitStatement -> UnitStatement -> Bool
$c== :: UnitStatement -> UnitStatement -> Bool
Eq, Typeable UnitStatement
DataType
Constr
Typeable UnitStatement
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> UnitStatement -> c UnitStatement)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c UnitStatement)
-> (UnitStatement -> Constr)
-> (UnitStatement -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c UnitStatement))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c UnitStatement))
-> ((forall b. Data b => b -> b) -> UnitStatement -> UnitStatement)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UnitStatement -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UnitStatement -> r)
-> (forall u. (forall d. Data d => d -> u) -> UnitStatement -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> UnitStatement -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement)
-> Data UnitStatement
UnitStatement -> DataType
UnitStatement -> Constr
(forall b. Data b => b -> b) -> UnitStatement -> UnitStatement
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitStatement -> c UnitStatement
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitStatement
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> UnitStatement -> u
forall u. (forall d. Data d => d -> u) -> UnitStatement -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitStatement -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitStatement -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitStatement
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitStatement -> c UnitStatement
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnitStatement)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnitStatement)
$cUnitAlias :: Constr
$cUnitAssignment :: Constr
$tUnitStatement :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
gmapMp :: (forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
gmapM :: (forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnitStatement -> m UnitStatement
gmapQi :: Int -> (forall d. Data d => d -> u) -> UnitStatement -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UnitStatement -> u
gmapQ :: (forall d. Data d => d -> u) -> UnitStatement -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UnitStatement -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitStatement -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitStatement -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitStatement -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitStatement -> r
gmapT :: (forall b. Data b => b -> b) -> UnitStatement -> UnitStatement
$cgmapT :: (forall b. Data b => b -> b) -> UnitStatement -> UnitStatement
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnitStatement)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnitStatement)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c UnitStatement)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnitStatement)
dataTypeOf :: UnitStatement -> DataType
$cdataTypeOf :: UnitStatement -> DataType
toConstr :: UnitStatement -> Constr
$ctoConstr :: UnitStatement -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitStatement
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitStatement
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitStatement -> c UnitStatement
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitStatement -> c UnitStatement
$cp1Data :: Typeable UnitStatement
Data)

instance Show UnitStatement where
  show :: UnitStatement -> String
show (UnitAssignment (Just [String]
ss) UnitOfMeasure
uom)
    = String
"= unit (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"," [String]
ss
  show (UnitAssignment Maybe [String]
Nothing UnitOfMeasure
uom)
    = String
"= unit (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
  show (UnitAlias String
s UnitOfMeasure
uom)
    = String
"= unit :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom

data UnitOfMeasure =
   Unitless
 | UnitBasic String
 | UnitProduct UnitOfMeasure UnitOfMeasure
 | UnitQuotient UnitOfMeasure UnitOfMeasure
 | UnitExponentiation UnitOfMeasure UnitPower
 | UnitRecord [(String, UnitOfMeasure)]
  deriving (Typeable UnitOfMeasure
DataType
Constr
Typeable UnitOfMeasure
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> UnitOfMeasure -> c UnitOfMeasure)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c UnitOfMeasure)
-> (UnitOfMeasure -> Constr)
-> (UnitOfMeasure -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c UnitOfMeasure))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c UnitOfMeasure))
-> ((forall b. Data b => b -> b) -> UnitOfMeasure -> UnitOfMeasure)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r)
-> (forall u. (forall d. Data d => d -> u) -> UnitOfMeasure -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> UnitOfMeasure -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure)
-> Data UnitOfMeasure
UnitOfMeasure -> DataType
UnitOfMeasure -> Constr
(forall b. Data b => b -> b) -> UnitOfMeasure -> UnitOfMeasure
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitOfMeasure -> c UnitOfMeasure
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitOfMeasure
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> UnitOfMeasure -> u
forall u. (forall d. Data d => d -> u) -> UnitOfMeasure -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitOfMeasure
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitOfMeasure -> c UnitOfMeasure
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnitOfMeasure)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnitOfMeasure)
$cUnitRecord :: Constr
$cUnitExponentiation :: Constr
$cUnitQuotient :: Constr
$cUnitProduct :: Constr
$cUnitBasic :: Constr
$cUnitless :: Constr
$tUnitOfMeasure :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
gmapMp :: (forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
gmapM :: (forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnitOfMeasure -> m UnitOfMeasure
gmapQi :: Int -> (forall d. Data d => d -> u) -> UnitOfMeasure -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UnitOfMeasure -> u
gmapQ :: (forall d. Data d => d -> u) -> UnitOfMeasure -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UnitOfMeasure -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitOfMeasure -> r
gmapT :: (forall b. Data b => b -> b) -> UnitOfMeasure -> UnitOfMeasure
$cgmapT :: (forall b. Data b => b -> b) -> UnitOfMeasure -> UnitOfMeasure
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnitOfMeasure)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnitOfMeasure)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c UnitOfMeasure)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnitOfMeasure)
dataTypeOf :: UnitOfMeasure -> DataType
$cdataTypeOf :: UnitOfMeasure -> DataType
toConstr :: UnitOfMeasure -> Constr
$ctoConstr :: UnitOfMeasure -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitOfMeasure
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitOfMeasure
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitOfMeasure -> c UnitOfMeasure
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitOfMeasure -> c UnitOfMeasure
$cp1Data :: Typeable UnitOfMeasure
Data, UnitOfMeasure -> UnitOfMeasure -> Bool
(UnitOfMeasure -> UnitOfMeasure -> Bool)
-> (UnitOfMeasure -> UnitOfMeasure -> Bool) -> Eq UnitOfMeasure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnitOfMeasure -> UnitOfMeasure -> Bool
$c/= :: UnitOfMeasure -> UnitOfMeasure -> Bool
== :: UnitOfMeasure -> UnitOfMeasure -> Bool
$c== :: UnitOfMeasure -> UnitOfMeasure -> Bool
Eq)

instance Show UnitOfMeasure where
  show :: UnitOfMeasure -> String
show UnitOfMeasure
Unitless      = String
"1"
  show (UnitBasic String
s) = String
s
  show (UnitProduct UnitOfMeasure
uom1 UnitOfMeasure
uom2)
    = UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom2
  show (UnitQuotient UnitOfMeasure
uom1 UnitOfMeasure
uom2)
    = UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" / " String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom2
  show (UnitExponentiation UnitOfMeasure
uom UnitPower
expt)
    = UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
uom  String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"** (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitPower -> String
forall a. Show a => a -> String
show UnitPower
expt String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
  show (UnitRecord [(String, UnitOfMeasure)]
recs)
    = String
"record (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", "
      (((String, UnitOfMeasure) -> String)
-> [(String, UnitOfMeasure)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (\ (String
n, UnitOfMeasure
u) -> String
n String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ UnitOfMeasure -> String
forall a. Show a => a -> String
show UnitOfMeasure
u) [(String, UnitOfMeasure)]
recs) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"

data UnitPower =
   UnitPowerInteger Integer
 | UnitPowerRational Integer Integer
 deriving (Typeable UnitPower
DataType
Constr
Typeable UnitPower
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> UnitPower -> c UnitPower)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c UnitPower)
-> (UnitPower -> Constr)
-> (UnitPower -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c UnitPower))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnitPower))
-> ((forall b. Data b => b -> b) -> UnitPower -> UnitPower)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UnitPower -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UnitPower -> r)
-> (forall u. (forall d. Data d => d -> u) -> UnitPower -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> UnitPower -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> UnitPower -> m UnitPower)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnitPower -> m UnitPower)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnitPower -> m UnitPower)
-> Data UnitPower
UnitPower -> DataType
UnitPower -> Constr
(forall b. Data b => b -> b) -> UnitPower -> UnitPower
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitPower -> c UnitPower
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitPower
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> UnitPower -> u
forall u. (forall d. Data d => d -> u) -> UnitPower -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitPower -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitPower -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitPower
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitPower -> c UnitPower
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnitPower)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnitPower)
$cUnitPowerRational :: Constr
$cUnitPowerInteger :: Constr
$tUnitPower :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
gmapMp :: (forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
gmapM :: (forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnitPower -> m UnitPower
gmapQi :: Int -> (forall d. Data d => d -> u) -> UnitPower -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UnitPower -> u
gmapQ :: (forall d. Data d => d -> u) -> UnitPower -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UnitPower -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitPower -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnitPower -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitPower -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnitPower -> r
gmapT :: (forall b. Data b => b -> b) -> UnitPower -> UnitPower
$cgmapT :: (forall b. Data b => b -> b) -> UnitPower -> UnitPower
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnitPower)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnitPower)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c UnitPower)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnitPower)
dataTypeOf :: UnitPower -> DataType
$cdataTypeOf :: UnitPower -> DataType
toConstr :: UnitPower -> Constr
$ctoConstr :: UnitPower -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitPower
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnitPower
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitPower -> c UnitPower
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnitPower -> c UnitPower
$cp1Data :: Typeable UnitPower
Data, UnitPower -> UnitPower -> Bool
(UnitPower -> UnitPower -> Bool)
-> (UnitPower -> UnitPower -> Bool) -> Eq UnitPower
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnitPower -> UnitPower -> Bool
$c/= :: UnitPower -> UnitPower -> Bool
== :: UnitPower -> UnitPower -> Bool
$c== :: UnitPower -> UnitPower -> Bool
Eq)

instance Show UnitPower where
  show :: UnitPower -> String
show (UnitPowerInteger Integer
i)      = Integer -> String
forall a. Show a => a -> String
show Integer
i
  show (UnitPowerRational Integer
i1 Integer
i2) = Integer -> String
forall a. Show a => a -> String
show Integer
i1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"/" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
i2