{-# OPTIONS_GHC -Wno-orphans #-}
{-# Language TypeFamilies, FlexibleInstances, FlexibleContexts, ScopedTypeVariables, Rank2Types, CPP #-}
module Csound.Typed.Types.Prim(
Sig(..), unSig, D(..), unD, Tab(..), unTab, Str(..), Spec(..), Wspec(..), renderTab,
BoolSig(..), unBoolSig, BoolD(..), unBoolD, Unit(..), unit, Val(..), hideGE, SigOrD,
Sig2, Sig3, Sig4, Sig5, Sig6, Sig7, Sig8,
Sig2_2, Sig2_3, Sig2_4, Sig2_5, Sig2_6, Sig2_7, Sig2_8,
D2, D3, D4, D5, D6,
preTab, preStringTab, TabSize(..), TabArgs(..), updateTabSize,
fromPreTab, getPreTabUnsafe, skipNorm, forceNorm,
nsamp, ftlen, ftchnls, ftsr, ftcps,
TabList, tabList, fromTabList, fromTabListD,
double, int, text,
idur, getSampleRate, getControlRate, getBlockSize, getZeroDbfs,
getBpm, setBpm,
ar, kr, ir, sig,
on0, on1, on2, on3,
quot', rem', div', mod', ceil', floor', round', int', frac',
when1, whens, untilDo, whileDo, boolSig,
equalsTo, notEqualsTo, lessThan, greaterThan, lessThanEquals, greaterThanEquals,
whenD1, whenDs, untilDoD, whileDoD, untilBeginD,
) where
import Prelude hiding ((<*))
import Control.Applicative hiding ((<*))
import Control.Monad
import Control.Monad.Trans.Class
import qualified Data.IntMap as IM
import qualified Data.Map as M
import Control.Monad.Trans.Reader
import Data.Default
import Data.Boolean
import Data.String
import Csound.Dynamic hiding (genId, double, int, str, when1, whens, ifBegin, ifEnd, elseBegin, untilBegin, untilEnd, untilDo, whileBegin, whileEnd, whileDo)
import qualified Csound.Dynamic as D(double, int, str, ifBegin, ifEnd, elseBegin, untilBegin, untilEnd, whileBegin, whileEnd)
import Csound.Typed.GlobalState.GE
import Csound.Typed.GlobalState.SE
import Csound.Typed.GlobalState.Options
import Csound.Typed.GlobalState.Opcodes(tableK, tableI)
data Sig
= Sig (GE E)
| PrimSig Double
unSig :: Sig -> GE E
unSig :: Sig -> GE E
unSig = Sig -> GE E
forall a. Val a => a -> GE E
toGE
data D
= D (GE E)
| PrimD Double
unD :: D -> GE E
unD :: D -> GE E
unD = D -> GE E
forall a. Val a => a -> GE E
toGE
newtype Str = Str { Str -> GE E
unStr :: GE E }
newtype Spec = Spec { Spec -> GE E
unSpec :: GE E }
newtype Wspec = Wspec { Wspec -> GE E
unWspec :: GE E }
type D2 = (D, D)
type D3 = (D, D, D)
type D4 = (D, D, D, D)
type D5 = (D, D, D, D, D)
type D6 = (D, D, D, D, D, D)
type Sig2 = (Sig, Sig)
type Sig3 = (Sig, Sig, Sig)
type Sig4 = (Sig, Sig, Sig, Sig)
type Sig5 = (Sig, Sig, Sig, Sig, Sig)
type Sig6 = (Sig, Sig, Sig, Sig, Sig, Sig)
type Sig7 = (Sig, Sig, Sig, Sig, Sig, Sig, Sig)
type Sig8 = (Sig, Sig, Sig, Sig, Sig, Sig, Sig, Sig)
type Sig2_2 = (Sig2, Sig2)
type Sig2_3 = (Sig2, Sig2, Sig2)
type Sig2_4 = (Sig2, Sig2, Sig2, Sig2)
type Sig2_5 = (Sig2, Sig2, Sig2, Sig2, Sig2)
type Sig2_6 = (Sig2, Sig2, Sig2, Sig2, Sig2, Sig2)
type Sig2_7 = (Sig2, Sig2, Sig2, Sig2, Sig2, Sig2, Sig2)
type Sig2_8 = (Sig2, Sig2, Sig2, Sig2, Sig2, Sig2, Sig2, Sig2)
data BoolSig
= BoolSig (GE E)
| PrimBoolSig Bool
unBoolSig :: BoolSig -> GE E
unBoolSig :: BoolSig -> GE E
unBoolSig = BoolSig -> GE E
forall a. Val a => a -> GE E
toGE
data BoolD
= BoolD (GE E)
| PrimBoolD Bool
unBoolD :: BoolD -> GE E
unBoolD :: BoolD -> GE E
unBoolD = BoolD -> GE E
forall a. Val a => a -> GE E
toGE
type instance BooleanOf Sig = BoolSig
type instance BooleanOf D = BoolD
type instance BooleanOf Str = BoolD
type instance BooleanOf Tab = BoolD
type instance BooleanOf Spec = BoolD
newtype Unit = Unit { Unit -> GE ()
unUnit :: GE () }
unit :: Unit
unit :: Unit
unit = GE () -> Unit
Unit (GE () -> Unit) -> GE () -> Unit
forall a b. (a -> b) -> a -> b
$ () -> GE ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if MIN_VERSION_base(4,11,0)
instance Semigroup Unit where
<> :: Unit -> Unit -> Unit
(<>) = Unit -> Unit -> Unit
mappendUnit
instance Monoid Unit where
mempty :: Unit
mempty = Unit
forall a. Default a => a
def
#else
instance Monoid Unit where
mempty = def
mappend = mappendUnit
#endif
mappendUnit :: Unit -> Unit -> Unit
mappendUnit :: Unit -> Unit -> Unit
mappendUnit Unit
a Unit
b = GE () -> Unit
Unit (GE () -> Unit) -> GE () -> Unit
forall a b. (a -> b) -> a -> b
$ (Unit -> GE ()
unUnit Unit
a) GE () -> GE () -> GE ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Unit -> GE ()
unUnit Unit
b)
instance Default Unit where
def :: Unit
def = Unit
unit
data Tab
= Tab (GE E)
| TabPre PreTab
preTab :: TabSize -> Int -> TabArgs -> Tab
preTab :: TabSize -> Int -> TabArgs -> Tab
preTab TabSize
size Int
gen TabArgs
args = PreTab -> Tab
TabPre (PreTab -> Tab) -> PreTab -> Tab
forall a b. (a -> b) -> a -> b
$ TabSize -> GenId -> TabArgs -> PreTab
PreTab TabSize
size (Int -> GenId
IntGenId Int
gen) TabArgs
args
preStringTab :: TabSize -> String -> TabArgs -> Tab
preStringTab :: TabSize -> String -> TabArgs -> Tab
preStringTab TabSize
size String
gen TabArgs
args = PreTab -> Tab
TabPre (PreTab -> Tab) -> PreTab -> Tab
forall a b. (a -> b) -> a -> b
$ TabSize -> GenId -> TabArgs -> PreTab
PreTab TabSize
size (String -> GenId
StringGenId String
gen) TabArgs
args
data PreTab = PreTab
{ PreTab -> TabSize
preTabSize :: TabSize
, PreTab -> GenId
preTabGen :: GenId
, PreTab -> TabArgs
preTabArgs :: TabArgs }
data TabSize
= SizePlain Int
| SizeDegree
{ TabSize -> Bool
hasGuardPoint :: Bool
, TabSize -> Int
sizeDegree :: Int
}
instance Default TabSize where
def :: TabSize
def = SizeDegree :: Bool -> Int -> TabSize
SizeDegree
{ hasGuardPoint :: Bool
hasGuardPoint = Bool
False
, sizeDegree :: Int
sizeDegree = Int
0 }
data TabArgs
= ArgsPlain (Reader Int [Double])
| FileAccess String [Double]
renderPreTab :: PreTab -> GE E
renderPreTab :: PreTab -> GE E
renderPreTab PreTab
a = ((Int -> E) -> GE Int -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> E
D.int (GE Int -> GE E) -> (Gen -> GE Int) -> Gen -> GE E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Gen -> GE Int
saveGen) (Gen -> GE E) -> GE Gen -> GE E
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PreTab -> GE Gen
fromPreTab PreTab
a
getPreTabUnsafe :: String -> Tab -> PreTab
getPreTabUnsafe :: String -> Tab -> PreTab
getPreTabUnsafe String
msg Tab
x = case Tab
x of
TabPre PreTab
a -> PreTab
a
Tab
_ -> String -> PreTab
forall a. HasCallStack => String -> a
error String
msg
fromPreTab :: PreTab -> GE Gen
fromPreTab :: PreTab -> GE Gen
fromPreTab PreTab
a = (Options -> Gen) -> GE Gen
forall a. (Options -> a) -> GE a
withOptions ((Options -> Gen) -> GE Gen) -> (Options -> Gen) -> GE Gen
forall a b. (a -> b) -> a -> b
$ \Options
opt -> TabFi -> PreTab -> Gen
go (Options -> TabFi
defTabFi Options
opt) PreTab
a
where
go :: TabFi -> PreTab -> Gen
go :: TabFi -> PreTab -> Gen
go TabFi
tabFi PreTab
tab = Int -> GenId -> [Double] -> Maybe String -> Gen
Gen Int
size (PreTab -> GenId
preTabGen PreTab
tab) [Double]
args Maybe String
file
where size :: Int
size = Int -> TabSize -> Int
defineTabSize (TabFi -> PreTab -> Int
getTabSizeBase TabFi
tabFi PreTab
tab) (PreTab -> TabSize
preTabSize PreTab
tab)
([Double]
args, Maybe String
file) = Int -> TabArgs -> ([Double], Maybe String)
defineTabArgs Int
size (PreTab -> TabArgs
preTabArgs PreTab
tab)
getTabSizeBase :: TabFi -> PreTab -> Int
getTabSizeBase :: TabFi -> PreTab -> Int
getTabSizeBase TabFi
tf PreTab
tab = case PreTab -> GenId
preTabGen PreTab
tab of
IntGenId Int
intId -> Int -> Int -> IntMap Int -> Int
forall a. a -> Int -> IntMap a -> a
IM.findWithDefault (TabFi -> Int
tabFiBase TabFi
tf) Int
intId (TabFi -> IntMap Int
tabFiGens TabFi
tf)
StringGenId String
stringId -> Int -> String -> Map String Int -> Int
forall k a. Ord k => a -> k -> Map k a -> a
M.findWithDefault (TabFi -> Int
tabFiBase TabFi
tf) String
stringId (TabFi -> Map String Int
tabNamedFiGens TabFi
tf)
defineTabSize :: Int -> TabSize -> Int
defineTabSize :: Int -> TabSize -> Int
defineTabSize Int
base TabSize
x = case TabSize
x of
SizePlain Int
n -> Int
n
SizeDegree Bool
guardPoint Int
degree ->
Bool -> Int -> Int
forall a. Num a => Bool -> a -> a
byGuardPoint Bool
guardPoint (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$
Int -> Int -> Int
forall b a. (Integral b, Num a) => b -> b -> a
byDegree Int
base Int
degree
where byGuardPoint :: Bool -> a -> a
byGuardPoint Bool
guardPoint
| Bool
guardPoint = (a -> a -> a
forall a. Num a => a -> a -> a
+ a
1)
| Bool
otherwise = a -> a
forall a. a -> a
id
byDegree :: b -> b -> a
byDegree b
zero b
n = a
2 a -> b -> a
forall a b. (Num a, Integral b) => a -> b -> a
^ b -> b -> b
forall a. Ord a => a -> a -> a
max b
0 (b
zero b -> b -> b
forall a. Num a => a -> a -> a
+ b
n)
defineTabArgs :: Int -> TabArgs -> ([Double], Maybe String)
defineTabArgs :: Int -> TabArgs -> ([Double], Maybe String)
defineTabArgs Int
size TabArgs
args = case TabArgs
args of
ArgsPlain Reader Int [Double]
as -> (Reader Int [Double] -> Int -> [Double]
forall r a. Reader r a -> r -> a
runReader Reader Int [Double]
as Int
size, Maybe String
forall a. Maybe a
Nothing)
FileAccess String
filename [Double]
as -> ([Double]
as, String -> Maybe String
forall a. a -> Maybe a
Just String
filename)
skipNorm :: Tab -> Tab
skipNorm :: Tab -> Tab
skipNorm Tab
x = case Tab
x of
Tab GE E
_ -> String -> Tab
forall a. HasCallStack => String -> a
error String
"you can skip normalization only for primitive tables (made with gen-routines)"
TabPre PreTab
a -> PreTab -> Tab
TabPre (PreTab -> Tab) -> PreTab -> Tab
forall a b. (a -> b) -> a -> b
$ PreTab
a{ preTabGen :: GenId
preTabGen = GenId -> GenId
skipNormGenId (GenId -> GenId) -> GenId -> GenId
forall a b. (a -> b) -> a -> b
$ PreTab -> GenId
preTabGen PreTab
a }
skipNormGenId :: GenId -> GenId
skipNormGenId :: GenId -> GenId
skipNormGenId = (Int -> Int) -> GenId -> GenId
mapIntGenId (Int -> Int
forall a. Num a => a -> a
negate (Int -> Int) -> (Int -> Int) -> Int -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int
forall a. Num a => a -> a
abs)
forceNorm :: Tab -> Tab
forceNorm :: Tab -> Tab
forceNorm Tab
x = case Tab
x of
Tab GE E
_ -> String -> Tab
forall a. HasCallStack => String -> a
error String
"you can force normalization only for primitive tables (made with gen-routines)"
TabPre PreTab
a -> PreTab -> Tab
TabPre (PreTab -> Tab) -> PreTab -> Tab
forall a b. (a -> b) -> a -> b
$ PreTab
a{ preTabGen :: GenId
preTabGen = GenId -> GenId
normGenId (GenId -> GenId) -> GenId -> GenId
forall a b. (a -> b) -> a -> b
$ PreTab -> GenId
preTabGen PreTab
a }
normGenId :: GenId -> GenId
normGenId :: GenId -> GenId
normGenId = (Int -> Int) -> GenId -> GenId
mapIntGenId Int -> Int
forall a. Num a => a -> a
abs
mapIntGenId :: (Int -> Int) -> GenId -> GenId
mapIntGenId :: (Int -> Int) -> GenId -> GenId
mapIntGenId Int -> Int
f GenId
genId = case GenId
genId of
IntGenId Int
intId -> Int -> GenId
IntGenId (Int -> Int
f Int
intId)
GenId
_ -> GenId
genId
updateTabSize :: (TabSize -> TabSize) -> Tab -> Tab
updateTabSize :: (TabSize -> TabSize) -> Tab -> Tab
updateTabSize TabSize -> TabSize
phi Tab
x = case Tab
x of
Tab GE E
_ -> String -> Tab
forall a. HasCallStack => String -> a
error String
"you can change size only for primitive tables (made with gen-routines)"
TabPre PreTab
a -> PreTab -> Tab
TabPre (PreTab -> Tab) -> PreTab -> Tab
forall a b. (a -> b) -> a -> b
$ PreTab
a{ preTabSize :: TabSize
preTabSize = TabSize -> TabSize
phi (TabSize -> TabSize) -> TabSize -> TabSize
forall a b. (a -> b) -> a -> b
$ PreTab -> TabSize
preTabSize PreTab
a }
data TabList = TabList { TabList -> GE E
unTabList :: GE E }
tabList :: [Tab] -> TabList
tabList :: [Tab] -> TabList
tabList [Tab]
xs = GE E -> TabList
TabList (GE E -> TabList) -> GE E -> TabList
forall a b. (a -> b) -> a -> b
$ [Gen] -> GE E
saveTabs ([Gen] -> GE E) -> GE [Gen] -> GE E
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (PreTab -> GE Gen) -> [PreTab] -> GE [Gen]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PreTab -> GE Gen
fromPreTab ([Tab] -> [PreTab]
getPreTabs [Tab]
xs)
where
getPreTabs :: [Tab] -> [PreTab]
getPreTabs = \case
[] -> []
Tab GE E
_ : [Tab]
as -> [Tab] -> [PreTab]
getPreTabs [Tab]
as
TabPre PreTab
a : [Tab]
as -> PreTab
a PreTab -> [PreTab] -> [PreTab]
forall a. a -> [a] -> [a]
: [Tab] -> [PreTab]
getPreTabs [Tab]
as
fromTabList :: TabList -> Sig -> Tab
fromTabList :: TabList -> Sig -> Tab
fromTabList TabList
ts Sig
knd = GE E -> Tab
Tab (GE E -> Tab) -> GE E -> Tab
forall a b. (a -> b) -> a -> b
$ do
E
ets <- TabList -> GE E
forall a. Val a => a -> GE E
toGE TabList
ts
E
eknd <- Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
knd
E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ E -> E -> E
tableK E
eknd E
ets
fromTabListD :: TabList -> D -> Tab
fromTabListD :: TabList -> D -> Tab
fromTabListD TabList
ts D
ind = GE E -> Tab
Tab (GE E -> Tab) -> GE E -> Tab
forall a b. (a -> b) -> a -> b
$ do
E
ets <- TabList -> GE E
forall a. Val a => a -> GE E
toGE TabList
ts
E
eind <- D -> GE E
forall a. Val a => a -> GE E
toGE D
ind
E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ E -> E -> E
tableI E
eind E
ets
double :: Double -> D
double :: Double -> D
double = Double -> D
PrimD
int :: Int -> D
int :: Int -> D
int = Double -> D
PrimD (Double -> D) -> (Int -> Double) -> Int -> D
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral
text :: String -> Str
text :: String -> Str
text = E -> Str
forall a. Val a => E -> a
fromE (E -> Str) -> (String -> E) -> String -> Str
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> E
D.str
instance IsString Str where
fromString :: String -> Str
fromString = String -> Str
text
idur :: D
idur :: D
idur = E -> D
forall a. Val a => E -> a
fromE (E -> D) -> E -> D
forall a b. (a -> b) -> a -> b
$ Int -> E
pn Int
3
getSampleRate :: D
getSampleRate :: D
getSampleRate = E -> D
forall a. Val a => E -> a
fromE (E -> D) -> E -> D
forall a b. (a -> b) -> a -> b
$ Var -> E
readOnlyVar (Rate -> String -> Var
VarVerbatim Rate
Ir String
"sr")
getControlRate :: D
getControlRate :: D
getControlRate = E -> D
forall a. Val a => E -> a
fromE (E -> D) -> E -> D
forall a b. (a -> b) -> a -> b
$ Var -> E
readOnlyVar (Rate -> String -> Var
VarVerbatim Rate
Ir String
"kr")
getBlockSize :: D
getBlockSize :: D
getBlockSize = E -> D
forall a. Val a => E -> a
fromE (E -> D) -> E -> D
forall a b. (a -> b) -> a -> b
$ Var -> E
readOnlyVar (Rate -> String -> Var
VarVerbatim Rate
Ir String
"ksmps")
getZeroDbfs :: D
getZeroDbfs :: D
getZeroDbfs = E -> D
forall a. Val a => E -> a
fromE (E -> D) -> E -> D
forall a b. (a -> b) -> a -> b
$ Var -> E
readOnlyVar (Rate -> String -> Var
VarVerbatim Rate
Ir String
"0dbfs")
getBpm :: Sig
getBpm :: Sig
getBpm = E -> Sig
forall a. Val a => E -> a
fromE (E -> Sig) -> E -> Sig
forall a b. (a -> b) -> a -> b
$ Var -> E
readOnlyVar Var
bpmVar
setBpm :: Sig -> SE ()
setBpm :: Sig -> SE ()
setBpm Sig
x = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ GE (Dep ()) -> Dep ()
forall a. GE (Dep a) -> Dep a
hideGEinDep (GE (Dep ()) -> Dep ()) -> GE (Dep ()) -> Dep ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()) -> GE E -> GE (Dep ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Var -> E -> Dep ()
forall (m :: * -> *). Monad m => Var -> E -> DepT m ()
writeVar Var
bpmVar) (Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
x)
ar :: Sig -> Sig
ar :: Sig -> Sig
ar Sig
x = case Sig
x of
PrimSig Double
a -> Double -> Sig
PrimSig Double
a
Sig GE E
expr -> GE E -> Sig
Sig (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Rate -> E -> E
setRate Rate
Ar) GE E
expr
kr :: Sig -> Sig
kr :: Sig -> Sig
kr Sig
x = case Sig
x of
PrimSig Double
a -> Double -> Sig
PrimSig Double
a
Sig GE E
expr -> GE E -> Sig
Sig (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Rate -> E -> E
setRate Rate
Kr) GE E
expr
ir :: Sig -> D
ir :: Sig -> D
ir Sig
x = case Sig
x of
PrimSig Double
a -> Double -> D
PrimD Double
a
Sig GE E
a -> GE E -> D
D (GE E -> D) -> GE E -> D
forall a b. (a -> b) -> a -> b
$ (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Rate -> E -> E
setRate Rate
Ir) GE E
a
sig :: D -> Sig
sig :: D -> Sig
sig D
x = case D
x of
PrimD Double
a -> Double -> Sig
PrimSig Double
a
D GE E
expr -> GE E -> Sig
Sig (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Rate -> E -> E
setRate Rate
Kr) GE E
expr
class Val a where
fromGE :: GE E -> a
toGE :: a -> GE E
fromE :: E -> a
fromE = GE E -> a
forall a. Val a => GE E -> a
fromGE (GE E -> a) -> (E -> GE E) -> E -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return
hideGE :: Val a => GE a -> a
hideGE :: GE a -> a
hideGE = GE E -> a
forall a. Val a => GE E -> a
fromGE (GE E -> a) -> (GE a -> GE E) -> GE a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GE (GE E) -> GE E
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (GE (GE E) -> GE E) -> (GE a -> GE (GE E)) -> GE a -> GE E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> GE E) -> GE a -> GE (GE E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> GE E
forall a. Val a => a -> GE E
toGE
instance Val Sig where
fromGE :: GE E -> Sig
fromGE = GE E -> Sig
Sig
toGE :: Sig -> GE E
toGE Sig
x = case Sig
x of
Sig GE E
a -> GE E
a
PrimSig Double
d -> E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ Double -> E
D.double Double
d
instance Val D where
fromGE :: GE E -> D
fromGE = GE E -> D
D
toGE :: D -> GE E
toGE D
x = case D
x of
D GE E
a -> GE E
a
PrimD Double
d -> E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ Double -> E
D.double Double
d
instance Val Str where { fromGE :: GE E -> Str
fromGE = GE E -> Str
Str ; toGE :: Str -> GE E
toGE = Str -> GE E
unStr }
instance Val Spec where { fromGE :: GE E -> Spec
fromGE = GE E -> Spec
Spec ; toGE :: Spec -> GE E
toGE = Spec -> GE E
unSpec }
instance Val Wspec where { fromGE :: GE E -> Wspec
fromGE = GE E -> Wspec
Wspec ; toGE :: Wspec -> GE E
toGE = Wspec -> GE E
unWspec}
instance Val TabList where { fromGE :: GE E -> TabList
fromGE = GE E -> TabList
TabList; toGE :: TabList -> GE E
toGE = TabList -> GE E
unTabList }
instance Val Tab where
fromGE :: GE E -> Tab
fromGE = GE E -> Tab
Tab
toGE :: Tab -> GE E
toGE = Tab -> GE E
unTab
unTab :: Tab -> GE E
unTab :: Tab -> GE E
unTab Tab
x = case Tab
x of
Tab GE E
a -> GE E
a
TabPre PreTab
a -> PreTab -> GE E
renderPreTab PreTab
a
renderTab :: Tab -> GE Int
renderTab :: Tab -> GE Int
renderTab Tab
x = case Tab
x of
TabPre PreTab
a -> Gen -> GE Int
saveGen (Gen -> GE Int) -> GE Gen -> GE Int
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PreTab -> GE Gen
fromPreTab PreTab
a
Tab GE E
_ -> String -> GE Int
forall a. HasCallStack => String -> a
error String
"table should be primitive"
instance Val BoolSig where
fromGE :: GE E -> BoolSig
fromGE = GE E -> BoolSig
BoolSig
toGE :: BoolSig -> GE E
toGE BoolSig
x = case BoolSig
x of
BoolSig GE E
a -> GE E
a
PrimBoolSig Bool
b -> E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ if Bool
b then E
forall b. Boolean b => b
true else E
forall b. Boolean b => b
false
instance Val BoolD where
fromGE :: GE E -> BoolD
fromGE = GE E -> BoolD
BoolD
toGE :: BoolD -> GE E
toGE BoolD
x = case BoolD
x of
BoolD GE E
a -> GE E
a
PrimBoolD Bool
b -> E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ if Bool
b then E
forall b. Boolean b => b
true else E
forall b. Boolean b => b
false
class (IsPrim a, RealFrac (PrimOf a), Val a, Floating a) => SigOrD a where
instance SigOrD Sig where
instance SigOrD D where
on0 :: Val a => E -> a
on0 :: E -> a
on0 = E -> a
forall a. Val a => E -> a
fromE
on1 :: (Val a, Val b) => (E -> E) -> (a -> b)
on1 :: (E -> E) -> a -> b
on1 E -> E
f a
a = GE E -> b
forall a. Val a => GE E -> a
fromGE (GE E -> b) -> GE E -> b
forall a b. (a -> b) -> a -> b
$ (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap E -> E
f (GE E -> GE E) -> GE E -> GE E
forall a b. (a -> b) -> a -> b
$ a -> GE E
forall a. Val a => a -> GE E
toGE a
a
on2 :: (Val a, Val b, Val c) => (E -> E -> E) -> (a -> b -> c)
on2 :: (E -> E -> E) -> a -> b -> c
on2 E -> E -> E
f a
a b
b = GE E -> c
forall a. Val a => GE E -> a
fromGE (GE E -> c) -> GE E -> c
forall a b. (a -> b) -> a -> b
$ (E -> E -> E) -> GE E -> GE E -> GE E
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 E -> E -> E
f (a -> GE E
forall a. Val a => a -> GE E
toGE a
a) (b -> GE E
forall a. Val a => a -> GE E
toGE b
b)
on3 :: (Val a, Val b, Val c, Val d) => (E -> E -> E -> E) -> (a -> b -> c -> d)
on3 :: (E -> E -> E -> E) -> a -> b -> c -> d
on3 E -> E -> E -> E
f a
a b
b c
c = GE E -> d
forall a. Val a => GE E -> a
fromGE (GE E -> d) -> GE E -> d
forall a b. (a -> b) -> a -> b
$ (E -> E -> E -> E) -> GE E -> GE E -> GE E -> GE E
forall (f :: * -> *) a b c d.
Applicative f =>
(a -> b -> c -> d) -> f a -> f b -> f c -> f d
liftA3 E -> E -> E -> E
f (a -> GE E
forall a. Val a => a -> GE E
toGE a
a) (b -> GE E
forall a. Val a => a -> GE E
toGE b
b) (c -> GE E
forall a. Val a => a -> GE E
toGE c
c)
op1 :: (Val a, Val b, IsPrim a, IsPrim b) => (PrimOf a -> PrimOf b) -> (E -> E) -> (a -> b)
op1 :: (PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1 PrimOf a -> PrimOf b
primFun E -> E
exprFun a
x = b -> (PrimOf a -> b) -> Maybe (PrimOf a) -> b
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ((E -> E) -> a -> b
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 E -> E
exprFun a
x) (PrimOf b -> b
forall a. IsPrim a => PrimOf a -> a
fromPrim (PrimOf b -> b) -> (PrimOf a -> PrimOf b) -> PrimOf a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimOf a -> PrimOf b
primFun) (a -> Maybe (PrimOf a)
forall a. IsPrim a => a -> Maybe (PrimOf a)
getPrim a
x)
op2 :: (Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) => (PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> (a -> b -> c)
op2 :: (PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf a -> PrimOf b -> PrimOf c
primFun E -> E -> E
exprFun a
xa b
xb = case (a -> Maybe (PrimOf a)
forall a. IsPrim a => a -> Maybe (PrimOf a)
getPrim a
xa, b -> Maybe (PrimOf b)
forall a. IsPrim a => a -> Maybe (PrimOf a)
getPrim b
xb) of
(Just PrimOf a
a, Just PrimOf b
b) -> PrimOf c -> c
forall a. IsPrim a => PrimOf a -> a
fromPrim (PrimOf c -> c) -> PrimOf c -> c
forall a b. (a -> b) -> a -> b
$ PrimOf a -> PrimOf b -> PrimOf c
primFun PrimOf a
a PrimOf b
b
(Maybe (PrimOf a), Maybe (PrimOf b))
_ -> (E -> E -> E) -> a -> b -> c
forall a b c. (Val a, Val b, Val c) => (E -> E -> E) -> a -> b -> c
on2 E -> E -> E
exprFun a
xa b
xb
instance Default Sig where def :: Sig
def = Sig
0
instance Default D where def :: D
def = D
0
instance Default Tab where def :: Tab
def = E -> Tab
forall a. Val a => E -> a
fromE E
0
instance Default Str where def :: Str
def = String -> Str
text String
""
instance Default Spec where def :: Spec
def = E -> Spec
forall a. Val a => E -> a
fromE E
0
instance Default TabList where def :: TabList
def = E -> TabList
forall a. Val a => E -> a
fromE E
0
#if MIN_VERSION_base(4,11,0)
instance Semigroup Sig where
<> :: Sig -> Sig -> Sig
(<>) = (E -> E -> E) -> Sig -> Sig -> Sig
forall a b c. (Val a, Val b, Val c) => (E -> E -> E) -> a -> b -> c
on2 E -> E -> E
forall a. Monoid a => a -> a -> a
mappend
instance Monoid Sig where
mempty :: Sig
mempty = E -> Sig
forall a. Val a => E -> a
on0 E
forall a. Monoid a => a
mempty
#else
instance Monoid Sig where
mempty = on0 mempty
mappend = on2 mappend
#endif
#if MIN_VERSION_base(4,11,0)
instance Semigroup D where
<> :: D -> D -> D
(<>) = (E -> E -> E) -> D -> D -> D
forall a b c. (Val a, Val b, Val c) => (E -> E -> E) -> a -> b -> c
on2 E -> E -> E
forall a. Monoid a => a -> a -> a
mappend
instance Monoid D where
mempty :: D
mempty = E -> D
forall a. Val a => E -> a
on0 E
forall a. Monoid a => a
mempty
#else
instance Monoid D where
mempty = on0 mempty
mappend = on2 mappend
#endif
sigOn1 :: (Double -> Double) -> (E -> E) -> (Sig -> Sig)
sigOn1 :: (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
numFun E -> E
exprFun Sig
x = case Sig
x of
PrimSig Double
a -> Double -> Sig
PrimSig (Double -> Sig) -> Double -> Sig
forall a b. (a -> b) -> a -> b
$ Double -> Double
numFun Double
a
Sig
_ -> (E -> E) -> Sig -> Sig
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 E -> E
exprFun Sig
x
sigOn2 :: (Double -> Double -> Double) -> (E -> E -> E) -> (Sig -> Sig -> Sig)
sigOn2 :: (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 Double -> Double -> Double
numFun E -> E -> E
exprFun Sig
xa Sig
xb = case (Sig
xa, Sig
xb) of
(PrimSig Double
a, PrimSig Double
b) -> Double -> Sig
PrimSig (Double -> Sig) -> Double -> Sig
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
numFun Double
a Double
b
(Sig, Sig)
_ -> (E -> E -> E) -> Sig -> Sig -> Sig
forall a b c. (Val a, Val b, Val c) => (E -> E -> E) -> a -> b -> c
on2 E -> E -> E
exprFun Sig
xa Sig
xb
instance Num Sig where
{ + :: Sig -> Sig -> Sig
(+) = (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 Double -> Double -> Double
forall a. Num a => a -> a -> a
(+) E -> E -> E
forall a. Num a => a -> a -> a
(+); * :: Sig -> Sig -> Sig
(*) = (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 Double -> Double -> Double
forall a. Num a => a -> a -> a
(*) E -> E -> E
forall a. Num a => a -> a -> a
(*); negate :: Sig -> Sig
negate = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Num a => a -> a
negate E -> E
forall a. Num a => a -> a
negate
; (-) = (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 (\Double
a Double
b -> Double
a Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
b) (\E
a E
b -> E
a E -> E -> E
forall a. Num a => a -> a -> a
- E
b)
; fromInteger :: Integer -> Sig
fromInteger = Double -> Sig
PrimSig (Double -> Sig) -> (Integer -> Double) -> Integer -> Sig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Double
forall a. Num a => Integer -> a
fromInteger; abs :: Sig -> Sig
abs = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Num a => a -> a
abs E -> E
forall a. Num a => a -> a
abs; signum :: Sig -> Sig
signum = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Num a => a -> a
signum E -> E
forall a. Num a => a -> a
signum }
dOn1 :: (Double -> Double) -> (E -> E) -> (D -> D)
dOn1 :: (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
numFun E -> E
exprFun D
x = case D
x of
PrimD Double
a -> Double -> D
PrimD (Double -> D) -> Double -> D
forall a b. (a -> b) -> a -> b
$ Double -> Double
numFun Double
a
D
_ -> (E -> E) -> D -> D
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 E -> E
exprFun D
x
dOn2 :: (Double -> Double -> Double) -> (E -> E -> E) -> (D -> D -> D)
dOn2 :: (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 Double -> Double -> Double
numFun E -> E -> E
exprFun D
xa D
xb = case (D
xa, D
xb) of
(PrimD Double
a, PrimD Double
b) -> Double -> D
PrimD (Double -> D) -> Double -> D
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
numFun Double
a Double
b
(D, D)
_ -> (E -> E -> E) -> D -> D -> D
forall a b c. (Val a, Val b, Val c) => (E -> E -> E) -> a -> b -> c
on2 E -> E -> E
exprFun D
xa D
xb
instance Num D where
{ + :: D -> D -> D
(+) = (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 Double -> Double -> Double
forall a. Num a => a -> a -> a
(+) E -> E -> E
forall a. Num a => a -> a -> a
(+); * :: D -> D -> D
(*) = (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 Double -> Double -> Double
forall a. Num a => a -> a -> a
(*) E -> E -> E
forall a. Num a => a -> a -> a
(*); negate :: D -> D
negate = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Num a => a -> a
negate E -> E
forall a. Num a => a -> a
negate
; (-) = (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 (\Double
a Double
b -> Double
a Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
b) (\E
a E
b -> E
a E -> E -> E
forall a. Num a => a -> a -> a
- E
b)
; fromInteger :: Integer -> D
fromInteger = Double -> D
PrimD (Double -> D) -> (Integer -> Double) -> Integer -> D
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Double
forall a. Num a => Integer -> a
fromInteger; abs :: D -> D
abs = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Num a => a -> a
abs E -> E
forall a. Num a => a -> a
abs; signum :: D -> D
signum = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Num a => a -> a
signum E -> E
forall a. Num a => a -> a
signum }
instance Fractional Sig where { / :: Sig -> Sig -> Sig
(/) = (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
(/) E -> E -> E
forall a. Fractional a => a -> a -> a
(/); fromRational :: Rational -> Sig
fromRational = Double -> Sig
PrimSig (Double -> Sig) -> (Rational -> Double) -> Rational -> Sig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Double
forall a. Fractional a => Rational -> a
fromRational }
instance Fractional D where { / :: D -> D -> D
(/) = (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
(/) E -> E -> E
forall a. Fractional a => a -> a -> a
(/); fromRational :: Rational -> D
fromRational = Double -> D
PrimD (Double -> D) -> (Rational -> Double) -> Rational -> D
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Double
forall a. Fractional a => Rational -> a
fromRational }
instance Floating Sig where
{ pi :: Sig
pi = Double -> Sig
PrimSig Double
forall a. Floating a => a
pi; exp :: Sig -> Sig
exp = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
exp E -> E
forall a. Floating a => a -> a
exp; sqrt :: Sig -> Sig
sqrt = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
sqrt E -> E
forall a. Floating a => a -> a
sqrt; log :: Sig -> Sig
log = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
log E -> E
forall a. Floating a => a -> a
log; logBase :: Sig -> Sig -> Sig
logBase = (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 Double -> Double -> Double
forall a. Floating a => a -> a -> a
logBase E -> E -> E
forall a. Floating a => a -> a -> a
logBase; ** :: Sig -> Sig -> Sig
(**) = (Double -> Double -> Double) -> (E -> E -> E) -> Sig -> Sig -> Sig
sigOn2 Double -> Double -> Double
forall a. Floating a => a -> a -> a
(**) E -> E -> E
forall a. Floating a => a -> a -> a
(**)
; sin :: Sig -> Sig
sin = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
sin E -> E
forall a. Floating a => a -> a
sin; tan :: Sig -> Sig
tan = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
tan E -> E
forall a. Floating a => a -> a
tan; cos :: Sig -> Sig
cos = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
cos E -> E
forall a. Floating a => a -> a
cos; sinh :: Sig -> Sig
sinh = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
sinh E -> E
forall a. Floating a => a -> a
sinh; tanh :: Sig -> Sig
tanh = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
tanh E -> E
forall a. Floating a => a -> a
tanh; cosh :: Sig -> Sig
cosh = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
cosh E -> E
forall a. Floating a => a -> a
cosh
; asin :: Sig -> Sig
asin = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
asin E -> E
forall a. Floating a => a -> a
asin; atan :: Sig -> Sig
atan = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
atan E -> E
forall a. Floating a => a -> a
atan; acos :: Sig -> Sig
acos = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
acos E -> E
forall a. Floating a => a -> a
acos ; asinh :: Sig -> Sig
asinh = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
asinh E -> E
forall a. Floating a => a -> a
asinh; acosh :: Sig -> Sig
acosh = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
acosh E -> E
forall a. Floating a => a -> a
acosh; atanh :: Sig -> Sig
atanh = (Double -> Double) -> (E -> E) -> Sig -> Sig
sigOn1 Double -> Double
forall a. Floating a => a -> a
atanh E -> E
forall a. Floating a => a -> a
atanh }
instance Floating D where
{ pi :: D
pi = Double -> D
PrimD Double
forall a. Floating a => a
pi; exp :: D -> D
exp = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
exp E -> E
forall a. Floating a => a -> a
exp; sqrt :: D -> D
sqrt = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
sqrt E -> E
forall a. Floating a => a -> a
sqrt; log :: D -> D
log = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
log E -> E
forall a. Floating a => a -> a
log; logBase :: D -> D -> D
logBase = (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 Double -> Double -> Double
forall a. Floating a => a -> a -> a
logBase E -> E -> E
forall a. Floating a => a -> a -> a
logBase; ** :: D -> D -> D
(**) = (Double -> Double -> Double) -> (E -> E -> E) -> D -> D -> D
dOn2 Double -> Double -> Double
forall a. Floating a => a -> a -> a
(**) E -> E -> E
forall a. Floating a => a -> a -> a
(**)
; sin :: D -> D
sin = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
sin E -> E
forall a. Floating a => a -> a
sin; tan :: D -> D
tan = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
tan E -> E
forall a. Floating a => a -> a
tan; cos :: D -> D
cos = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
cos E -> E
forall a. Floating a => a -> a
cos; sinh :: D -> D
sinh = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
sinh E -> E
forall a. Floating a => a -> a
sinh; tanh :: D -> D
tanh = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
tanh E -> E
forall a. Floating a => a -> a
tanh; cosh :: D -> D
cosh = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
cosh E -> E
forall a. Floating a => a -> a
cosh
; asin :: D -> D
asin = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
asin E -> E
forall a. Floating a => a -> a
asin; atan :: D -> D
atan = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
atan E -> E
forall a. Floating a => a -> a
atan; acos :: D -> D
acos = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
acos E -> E
forall a. Floating a => a -> a
acos ; asinh :: D -> D
asinh = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
asinh E -> E
forall a. Floating a => a -> a
asinh; acosh :: D -> D
acosh = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
acosh E -> E
forall a. Floating a => a -> a
acosh; atanh :: D -> D
atanh = (Double -> Double) -> (E -> E) -> D -> D
dOn1 Double -> Double
forall a. Floating a => a -> a
atanh E -> E
forall a. Floating a => a -> a
atanh }
class IsPrim a where
type PrimOf a :: *
getPrim :: a -> Maybe (PrimOf a)
fromPrim :: PrimOf a -> a
instance IsPrim Sig where
type PrimOf Sig = Double
getPrim :: Sig -> Maybe (PrimOf Sig)
getPrim Sig
x = case Sig
x of
PrimSig Double
a -> Double -> Maybe Double
forall a. a -> Maybe a
Just Double
a
Sig
_ -> Maybe (PrimOf Sig)
forall a. Maybe a
Nothing
fromPrim :: PrimOf Sig -> Sig
fromPrim = Double -> Sig
PrimOf Sig -> Sig
PrimSig
instance IsPrim D where
type PrimOf D = Double
getPrim :: D -> Maybe (PrimOf D)
getPrim D
x = case D
x of
PrimD Double
a -> Double -> Maybe Double
forall a. a -> Maybe a
Just Double
a
D
_ -> Maybe (PrimOf D)
forall a. Maybe a
Nothing
fromPrim :: PrimOf D -> D
fromPrim = Double -> D
PrimOf D -> D
PrimD
instance IsPrim BoolSig where
type PrimOf BoolSig = Bool
getPrim :: BoolSig -> Maybe (PrimOf BoolSig)
getPrim BoolSig
x = case BoolSig
x of
PrimBoolSig Bool
a -> Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
a
BoolSig
_ -> Maybe (PrimOf BoolSig)
forall a. Maybe a
Nothing
fromPrim :: PrimOf BoolSig -> BoolSig
fromPrim = Bool -> BoolSig
PrimOf BoolSig -> BoolSig
PrimBoolSig
instance IsPrim BoolD where
type PrimOf BoolD = Bool
getPrim :: BoolD -> Maybe (PrimOf BoolD)
getPrim BoolD
x = case BoolD
x of
PrimBoolD Bool
a -> Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
a
BoolD
_ -> Maybe (PrimOf BoolD)
forall a. Maybe a
Nothing
fromPrim :: PrimOf BoolD -> BoolD
fromPrim = Bool -> BoolD
PrimOf BoolD -> BoolD
PrimBoolD
ceil', floor', int', round' :: SigOrD a => a -> a
quot', rem', div', mod' :: SigOrD a => a -> a -> a
frac' :: (SigOrD a) => a -> a
frac' :: a -> a
frac' a
a = (PrimOf a -> PrimOf a) -> (E -> E) -> a -> a
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1 (\PrimOf a
x -> a -> (Int, PrimOf a) -> PrimOf a
forall a. SigOrD a => a -> (Int, PrimOf a) -> PrimOf a
proxySnd a
a (PrimOf a -> (Int, PrimOf a)
forall a b. (RealFrac a, Integral b) => a -> (b, a)
properFraction PrimOf a
x)) E -> E
fracE a
a
where
proxySnd :: SigOrD a => a -> (Int, PrimOf a) -> PrimOf a
proxySnd :: a -> (Int, PrimOf a) -> PrimOf a
proxySnd a
_ (Int, PrimOf a)
x = (Int, PrimOf a) -> PrimOf a
forall a b. (a, b) -> b
snd (Int, PrimOf a)
x
ceil' :: a -> a
ceil' = (PrimOf a -> PrimOf a) -> (E -> E) -> a -> a
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1 (\PrimOf a
x -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
ceiling PrimOf a
x) :: Int)) E -> E
ceilE
floor' :: a -> a
floor' = (PrimOf a -> PrimOf a) -> (E -> E) -> a -> a
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1 (\PrimOf a
x -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
floor PrimOf a
x) :: Int)) E -> E
floorE
int' :: a -> a
int' = (PrimOf a -> PrimOf a) -> (E -> E) -> a -> a
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1 (\PrimOf a
x -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
x) :: Int)) E -> E
intE
round' :: a -> a
round' = (PrimOf a -> PrimOf a) -> (E -> E) -> a -> a
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1 (\PrimOf a
x -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
round PrimOf a
x) :: Int)) E -> E
roundE
quot' :: a -> a -> a
quot' = (PrimOf a -> PrimOf a -> PrimOf a) -> (E -> E -> E) -> a -> a -> a
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 (\PrimOf a
a PrimOf a
b -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> PrimOf a) -> Int -> PrimOf a
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int
forall a. Integral a => a -> a -> a
quot ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
a) :: Int) ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
b):: Int)) E -> E -> E
forall a. Integral a => a -> a -> a
quot
rem' :: a -> a -> a
rem' = (PrimOf a -> PrimOf a -> PrimOf a) -> (E -> E -> E) -> a -> a -> a
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 (\PrimOf a
a PrimOf a
b -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> PrimOf a) -> Int -> PrimOf a
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int
forall a. Integral a => a -> a -> a
rem ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
a) :: Int) ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
b):: Int)) E -> E -> E
forall a. Integral a => a -> a -> a
rem
div' :: a -> a -> a
div' = (PrimOf a -> PrimOf a -> PrimOf a) -> (E -> E -> E) -> a -> a -> a
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 (\PrimOf a
a PrimOf a
b -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> PrimOf a) -> Int -> PrimOf a
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int
forall a. Integral a => a -> a -> a
div ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
a) :: Int) ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
b):: Int)) E -> E -> E
forall a. Integral a => a -> a -> a
div
mod' :: a -> a -> a
mod' = (PrimOf a -> PrimOf a -> PrimOf a) -> (E -> E -> E) -> a -> a -> a
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 (\PrimOf a
a PrimOf a
b -> Int -> PrimOf a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> PrimOf a) -> Int -> PrimOf a
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
a) :: Int) ((PrimOf a -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate PrimOf a
b):: Int)) E -> E -> E
forall a. Integral a => a -> a -> a
mod
boolSigOn1 :: (Bool -> Bool) -> (E -> E) -> BoolSig -> BoolSig
boolSigOn1 :: (Bool -> Bool) -> (E -> E) -> BoolSig -> BoolSig
boolSigOn1 = (Bool -> Bool) -> (E -> E) -> BoolSig -> BoolSig
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1
boolSigOn2 :: (Bool -> Bool -> Bool) -> (E -> E -> E) -> BoolSig -> BoolSig -> BoolSig
boolSigOn2 :: (Bool -> Bool -> Bool)
-> (E -> E -> E) -> BoolSig -> BoolSig -> BoolSig
boolSigOn2 = (Bool -> Bool -> Bool)
-> (E -> E -> E) -> BoolSig -> BoolSig -> BoolSig
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2
boolDOn1 :: (Bool -> Bool) -> (E -> E) -> BoolD -> BoolD
boolDOn1 :: (Bool -> Bool) -> (E -> E) -> BoolD -> BoolD
boolDOn1 = (Bool -> Bool) -> (E -> E) -> BoolD -> BoolD
forall a b.
(Val a, Val b, IsPrim a, IsPrim b) =>
(PrimOf a -> PrimOf b) -> (E -> E) -> a -> b
op1
boolDOn2 :: (Bool -> Bool -> Bool) -> (E -> E -> E) -> BoolD -> BoolD -> BoolD
boolDOn2 :: (Bool -> Bool -> Bool) -> (E -> E -> E) -> BoolD -> BoolD -> BoolD
boolDOn2 = (Bool -> Bool -> Bool) -> (E -> E -> E) -> BoolD -> BoolD -> BoolD
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2
instance Boolean BoolSig where { true :: BoolSig
true = Bool -> BoolSig
PrimBoolSig Bool
True; false :: BoolSig
false = Bool -> BoolSig
PrimBoolSig Bool
False; notB :: BoolSig -> BoolSig
notB = (Bool -> Bool) -> (E -> E) -> BoolSig -> BoolSig
boolSigOn1 Bool -> Bool
not E -> E
forall b. Boolean b => b -> b
notB; &&* :: BoolSig -> BoolSig -> BoolSig
(&&*) = (Bool -> Bool -> Bool)
-> (E -> E -> E) -> BoolSig -> BoolSig -> BoolSig
boolSigOn2 Bool -> Bool -> Bool
(&&) E -> E -> E
forall b. Boolean b => b -> b -> b
(&&*); ||* :: BoolSig -> BoolSig -> BoolSig
(||*) = (Bool -> Bool -> Bool)
-> (E -> E -> E) -> BoolSig -> BoolSig -> BoolSig
boolSigOn2 Bool -> Bool -> Bool
(||) E -> E -> E
forall b. Boolean b => b -> b -> b
(||*) }
instance Boolean BoolD where { true :: BoolD
true = Bool -> BoolD
PrimBoolD Bool
True; false :: BoolD
false = Bool -> BoolD
PrimBoolD Bool
False; notB :: BoolD -> BoolD
notB = (Bool -> Bool) -> (E -> E) -> BoolD -> BoolD
boolDOn1 Bool -> Bool
not E -> E
forall b. Boolean b => b -> b
notB; &&* :: BoolD -> BoolD -> BoolD
(&&*) = (Bool -> Bool -> Bool) -> (E -> E -> E) -> BoolD -> BoolD -> BoolD
boolDOn2 Bool -> Bool -> Bool
(&&) E -> E -> E
forall b. Boolean b => b -> b -> b
(&&*); ||* :: BoolD -> BoolD -> BoolD
(||*) = (Bool -> Bool -> Bool) -> (E -> E -> E) -> BoolD -> BoolD -> BoolD
boolDOn2 Bool -> Bool -> Bool
(||) E -> E -> E
forall b. Boolean b => b -> b -> b
(||*) }
instance IfB Sig where
ifB :: bool -> Sig -> Sig -> Sig
ifB bool
x Sig
a Sig
b = case bool
x of
PrimBoolSig c -> if Bool
c then Sig
a else Sig
b
bool
_ -> (E -> E -> E -> E) -> bool -> Sig -> Sig -> Sig
forall a b c d.
(Val a, Val b, Val c, Val d) =>
(E -> E -> E -> E) -> a -> b -> c -> d
on3 E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
x Sig
a Sig
b
instance IfB D where
ifB :: bool -> D -> D -> D
ifB bool
x D
a D
b = case bool
x of
PrimBoolD c -> if Bool
c then D
a else D
b
bool
_ -> (E -> E -> E -> E) -> bool -> D -> D -> D
forall a b c d.
(Val a, Val b, Val c, Val d) =>
(E -> E -> E -> E) -> a -> b -> c -> d
on3 E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
x D
a D
b
instance IfB Tab where
ifB :: bool -> Tab -> Tab -> Tab
ifB bool
x Tab
a Tab
b = case bool
x of
PrimBoolD c -> if Bool
c then Tab
a else Tab
b
bool
_ -> (E -> E -> E -> E) -> bool -> Tab -> Tab -> Tab
forall a b c d.
(Val a, Val b, Val c, Val d) =>
(E -> E -> E -> E) -> a -> b -> c -> d
on3 E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
x Tab
a Tab
b
instance IfB Str where
ifB :: bool -> Str -> Str -> Str
ifB bool
x Str
a Str
b = case bool
x of
PrimBoolD c -> if Bool
c then Str
a else Str
b
bool
_ -> (E -> E -> E -> E) -> bool -> Str -> Str -> Str
forall a b c d.
(Val a, Val b, Val c, Val d) =>
(E -> E -> E -> E) -> a -> b -> c -> d
on3 E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
x Str
a Str
b
instance IfB Spec where
ifB :: bool -> Spec -> Spec -> Spec
ifB bool
x Spec
a Spec
b = case bool
x of
PrimBoolD c -> if Bool
c then Spec
a else Spec
b
bool
_ -> (E -> E -> E -> E) -> bool -> Spec -> Spec -> Spec
forall a b c d.
(Val a, Val b, Val c, Val d) =>
(E -> E -> E -> E) -> a -> b -> c -> d
on3 E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB bool
x Spec
a Spec
b
instance EqB Sig where { ==* :: Sig -> Sig -> bool
(==*) = (PrimOf Sig -> PrimOf Sig -> PrimOf bool)
-> (E -> E -> E) -> Sig -> Sig -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf Sig -> PrimOf Sig -> PrimOf bool
forall a. Eq a => a -> a -> Bool
(==) E -> E -> E
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
(==*); /=* :: Sig -> Sig -> bool
(/=*) = (PrimOf Sig -> PrimOf Sig -> PrimOf bool)
-> (E -> E -> E) -> Sig -> Sig -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf Sig -> PrimOf Sig -> PrimOf bool
forall a. Eq a => a -> a -> Bool
(/=) E -> E -> E
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
(/=*) }
instance EqB D where { ==* :: D -> D -> bool
(==*) = (PrimOf D -> PrimOf D -> PrimOf bool)
-> (E -> E -> E) -> D -> D -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf D -> PrimOf D -> PrimOf bool
forall a. Eq a => a -> a -> Bool
(==) E -> E -> E
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
(==*); /=* :: D -> D -> bool
(/=*) = (PrimOf D -> PrimOf D -> PrimOf bool)
-> (E -> E -> E) -> D -> D -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf D -> PrimOf D -> PrimOf bool
forall a. Eq a => a -> a -> Bool
(/=) E -> E -> E
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
(/=*) }
instance OrdB Sig where { <* :: Sig -> Sig -> bool
(<*) = (PrimOf Sig -> PrimOf Sig -> PrimOf bool)
-> (E -> E -> E) -> Sig -> Sig -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf Sig -> PrimOf Sig -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(<) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(<*) ; >* :: Sig -> Sig -> bool
(>*) = (PrimOf Sig -> PrimOf Sig -> PrimOf bool)
-> (E -> E -> E) -> Sig -> Sig -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf Sig -> PrimOf Sig -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(>) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(>*); <=* :: Sig -> Sig -> bool
(<=*) = (PrimOf Sig -> PrimOf Sig -> PrimOf bool)
-> (E -> E -> E) -> Sig -> Sig -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf Sig -> PrimOf Sig -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(<=) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(<=*); >=* :: Sig -> Sig -> bool
(>=*) = (PrimOf Sig -> PrimOf Sig -> PrimOf bool)
-> (E -> E -> E) -> Sig -> Sig -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf Sig -> PrimOf Sig -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(>=) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(>=*) }
instance OrdB D where { <* :: D -> D -> bool
(<*) = (PrimOf D -> PrimOf D -> PrimOf bool)
-> (E -> E -> E) -> D -> D -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf D -> PrimOf D -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(<) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(<*) ; >* :: D -> D -> bool
(>*) = (PrimOf D -> PrimOf D -> PrimOf bool)
-> (E -> E -> E) -> D -> D -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf D -> PrimOf D -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(>) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(>*); <=* :: D -> D -> bool
(<=*) = (PrimOf D -> PrimOf D -> PrimOf bool)
-> (E -> E -> E) -> D -> D -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf D -> PrimOf D -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(<=) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(<=*); >=* :: D -> D -> bool
(>=*) = (PrimOf D -> PrimOf D -> PrimOf bool)
-> (E -> E -> E) -> D -> D -> bool
forall a b c.
(Val a, Val b, Val c, IsPrim a, IsPrim b, IsPrim c) =>
(PrimOf a -> PrimOf b -> PrimOf c) -> (E -> E -> E) -> a -> b -> c
op2 PrimOf D -> PrimOf D -> PrimOf bool
forall a. Ord a => a -> a -> Bool
(>=) E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(>=*) }
when1 :: BoolSig -> SE () -> SE ()
when1 :: BoolSig -> SE () -> SE ()
when1 BoolSig
xp SE ()
body = case BoolSig
xp of
PrimBoolSig Bool
p -> if Bool
p then SE ()
body else () -> SE ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
BoolSig
_ -> do
BoolSig -> SE ()
ifBegin BoolSig
xp
SE ()
body
SE ()
ifEnd
whens :: [(BoolSig, SE ())] -> SE () -> SE ()
whens :: [(BoolSig, SE ())] -> SE () -> SE ()
whens [(BoolSig, SE ())]
bodies SE ()
el = case [(BoolSig, SE ())]
bodies of
[] -> SE ()
el
(BoolSig, SE ())
a:[(BoolSig, SE ())]
as -> do
BoolSig -> SE ()
ifBegin ((BoolSig, SE ()) -> BoolSig
forall a b. (a, b) -> a
fst (BoolSig, SE ())
a)
(BoolSig, SE ()) -> SE ()
forall a b. (a, b) -> b
snd (BoolSig, SE ())
a
[(BoolSig, SE ())] -> SE ()
forall b. [(BoolSig, SE b)] -> SE ()
elseIfs [(BoolSig, SE ())]
as
SE ()
elseBegin
SE ()
el
(SE () -> SE () -> SE ()) -> [SE ()] -> SE ()
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 SE () -> SE () -> SE ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>) ([SE ()] -> SE ()) -> [SE ()] -> SE ()
forall a b. (a -> b) -> a -> b
$ Int -> SE () -> [SE ()]
forall a. Int -> a -> [a]
replicate ([(BoolSig, SE ())] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(BoolSig, SE ())]
bodies) SE ()
ifEnd
where elseIfs :: [(BoolSig, SE b)] -> SE ()
elseIfs = ((BoolSig, SE b) -> SE b) -> [(BoolSig, SE b)] -> SE ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\(BoolSig
p, SE b
body) -> SE ()
elseBegin SE () -> SE () -> SE ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> BoolSig -> SE ()
ifBegin BoolSig
p SE () -> SE b -> SE b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SE b
body)
ifBegin :: BoolSig -> SE ()
ifBegin :: BoolSig -> SE ()
ifBegin BoolSig
a = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ Rate -> E -> Dep ()
forall (m :: * -> *). Monad m => Rate -> E -> DepT m ()
D.ifBegin Rate
Kr (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (BoolSig -> GE E
forall a. Val a => a -> GE E
toGE BoolSig
a)
ifEnd :: SE ()
ifEnd :: SE ()
ifEnd = Dep () -> SE ()
fromDep_ Dep ()
forall (m :: * -> *). Monad m => DepT m ()
D.ifEnd
elseBegin :: SE ()
elseBegin :: SE ()
elseBegin = Dep () -> SE ()
fromDep_ Dep ()
forall (m :: * -> *). Monad m => DepT m ()
D.elseBegin
whenD1 :: BoolD -> SE () -> SE ()
whenD1 :: BoolD -> SE () -> SE ()
whenD1 BoolD
xp SE ()
body = case BoolD
xp of
PrimBoolD Bool
p -> if Bool
p then SE ()
body else () -> SE ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
BoolD
_ -> do
BoolD -> SE ()
ifBeginD BoolD
xp
SE ()
body
SE ()
ifEnd
whenDs :: [(BoolD, SE ())] -> SE () -> SE ()
whenDs :: [(BoolD, SE ())] -> SE () -> SE ()
whenDs [(BoolD, SE ())]
bodies SE ()
el = case [(BoolD, SE ())]
bodies of
[] -> SE ()
el
(BoolD, SE ())
a:[(BoolD, SE ())]
as -> do
BoolD -> SE ()
ifBeginD ((BoolD, SE ()) -> BoolD
forall a b. (a, b) -> a
fst (BoolD, SE ())
a)
(BoolD, SE ()) -> SE ()
forall a b. (a, b) -> b
snd (BoolD, SE ())
a
[(BoolD, SE ())] -> SE ()
forall b. [(BoolD, SE b)] -> SE ()
elseIfs [(BoolD, SE ())]
as
SE ()
elseBegin
SE ()
el
(SE () -> SE () -> SE ()) -> [SE ()] -> SE ()
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 SE () -> SE () -> SE ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(>>) ([SE ()] -> SE ()) -> [SE ()] -> SE ()
forall a b. (a -> b) -> a -> b
$ Int -> SE () -> [SE ()]
forall a. Int -> a -> [a]
replicate ([(BoolD, SE ())] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(BoolD, SE ())]
bodies) SE ()
ifEnd
where elseIfs :: [(BoolD, SE b)] -> SE ()
elseIfs = ((BoolD, SE b) -> SE b) -> [(BoolD, SE b)] -> SE ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\(BoolD
p, SE b
body) -> SE ()
elseBegin SE () -> SE () -> SE ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> BoolD -> SE ()
ifBeginD BoolD
p SE () -> SE b -> SE b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SE b
body)
ifBeginD :: BoolD -> SE ()
ifBeginD :: BoolD -> SE ()
ifBeginD BoolD
a = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ Rate -> E -> Dep ()
forall (m :: * -> *). Monad m => Rate -> E -> DepT m ()
D.ifBegin Rate
Ir (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (BoolD -> GE E
forall a. Val a => a -> GE E
toGE BoolD
a)
untilDo :: BoolSig -> SE () -> SE ()
untilDo :: BoolSig -> SE () -> SE ()
untilDo BoolSig
p SE ()
body = do
BoolSig -> SE ()
untilBegin BoolSig
p
SE ()
body
SE ()
untilEnd
whileDo :: BoolSig -> SE () -> SE ()
whileDo :: BoolSig -> SE () -> SE ()
whileDo BoolSig
p SE ()
body = do
BoolSig -> SE ()
whileBegin BoolSig
p
SE ()
body
SE ()
whileEnd
whileBegin :: BoolSig -> SE ()
whileBegin :: BoolSig -> SE ()
whileBegin BoolSig
a = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
D.whileBegin (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (BoolSig -> GE E
forall a. Val a => a -> GE E
toGE BoolSig
a)
whileEnd :: SE ()
whileEnd :: SE ()
whileEnd = Dep () -> SE ()
fromDep_ Dep ()
forall (m :: * -> *). Monad m => DepT m ()
D.whileEnd
untilBegin :: BoolSig -> SE ()
untilBegin :: BoolSig -> SE ()
untilBegin BoolSig
a = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
D.untilBegin (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (BoolSig -> GE E
forall a. Val a => a -> GE E
toGE BoolSig
a)
untilEnd :: SE ()
untilEnd :: SE ()
untilEnd = Dep () -> SE ()
fromDep_ Dep ()
forall (m :: * -> *). Monad m => DepT m ()
D.untilEnd
untilDoD :: BoolD -> SE () -> SE ()
untilDoD :: BoolD -> SE () -> SE ()
untilDoD BoolD
p SE ()
body = do
BoolD -> SE ()
untilBeginD BoolD
p
SE ()
body
SE ()
untilEnd
whileDoD :: BoolD -> SE () -> SE ()
whileDoD :: BoolD -> SE () -> SE ()
whileDoD BoolD
p SE ()
body = do
BoolD -> SE ()
whileBeginD BoolD
p
SE ()
body
SE ()
whileEnd
whileBeginD :: BoolD -> SE ()
whileBeginD :: BoolD -> SE ()
whileBeginD BoolD
a = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
D.whileBegin (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (BoolD -> GE E
forall a. Val a => a -> GE E
toGE BoolD
a)
untilBeginD :: BoolD -> SE ()
untilBeginD :: BoolD -> SE ()
untilBeginD BoolD
a = Dep () -> SE ()
fromDep_ (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
D.untilBegin (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (BoolD -> GE E
forall a. Val a => a -> GE E
toGE BoolD
a)
boolSig :: BoolD -> BoolSig
boolSig :: BoolD -> BoolSig
boolSig BoolD
x = case BoolD
x of
PrimBoolD Bool
b -> Bool -> BoolSig
PrimBoolSig Bool
b
BoolD GE E
a -> GE E -> BoolSig
BoolSig GE E
a
infix 4 `equalsTo`, `notEqualsTo`, `lessThan`, `lessThanEquals`, `greaterThanEquals`, `greaterThan`
equalsTo :: EqB a => a -> a -> BooleanOf a
equalsTo :: a -> a -> BooleanOf a
equalsTo = a -> a -> BooleanOf a
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
(==*)
notEqualsTo :: EqB a => a -> a -> BooleanOf a
notEqualsTo :: a -> a -> BooleanOf a
notEqualsTo = a -> a -> BooleanOf a
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
(/=*)
lessThan :: OrdB a => a -> a -> BooleanOf a
lessThan :: a -> a -> BooleanOf a
lessThan = a -> a -> BooleanOf a
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(<*)
greaterThan :: OrdB a => a -> a -> BooleanOf a
greaterThan :: a -> a -> BooleanOf a
greaterThan = a -> a -> BooleanOf a
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(>*)
lessThanEquals :: OrdB a => a -> a -> BooleanOf a
lessThanEquals :: a -> a -> BooleanOf a
lessThanEquals = a -> a -> BooleanOf a
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(<=*)
greaterThanEquals :: OrdB a => a -> a -> BooleanOf a
greaterThanEquals :: a -> a -> BooleanOf a
greaterThanEquals = a -> a -> BooleanOf a
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
(>=*)
nsamp :: Tab -> D
nsamp :: Tab -> D
nsamp = (E -> E) -> Tab -> D
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 ((E -> E) -> Tab -> D) -> (E -> E) -> Tab -> D
forall a b. (a -> b) -> a -> b
$ String -> E -> E
opr1 String
"nsamp"
ftlen :: Tab -> D
ftlen :: Tab -> D
ftlen = (E -> E) -> Tab -> D
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 ((E -> E) -> Tab -> D) -> (E -> E) -> Tab -> D
forall a b. (a -> b) -> a -> b
$ String -> E -> E
opr1 String
"ftlen"
ftchnls :: Tab -> D
ftchnls :: Tab -> D
ftchnls = (E -> E) -> Tab -> D
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 ((E -> E) -> Tab -> D) -> (E -> E) -> Tab -> D
forall a b. (a -> b) -> a -> b
$ String -> E -> E
opr1 String
"ftchnls"
ftsr :: Tab -> D
ftsr :: Tab -> D
ftsr = (E -> E) -> Tab -> D
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 ((E -> E) -> Tab -> D) -> (E -> E) -> Tab -> D
forall a b. (a -> b) -> a -> b
$ String -> E -> E
opr1 String
"ftsr"
ftcps :: Tab -> D
ftcps :: Tab -> D
ftcps = (E -> E) -> Tab -> D
forall a b. (Val a, Val b) => (E -> E) -> a -> b
on1 ((E -> E) -> Tab -> D) -> (E -> E) -> Tab -> D
forall a b. (a -> b) -> a -> b
$ String -> E -> E
opr1 String
"ftcps"
instance (Num a1, Num a2, Num a3, Num a4, Num a5, Num a6, Num a7, Num a8) => Num (a1, a2, a3, a4, a5, a6, a7, a8) where
(a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) + :: (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
+ (a1
b1, a2
b2, a3
b3, a4
b4, a5
b5, a6
b6, a7
b7, a8
b8) = (a1
a1 a1 -> a1 -> a1
forall a. Num a => a -> a -> a
+ a1
b1, a2
a2 a2 -> a2 -> a2
forall a. Num a => a -> a -> a
+ a2
b2, a3
a3 a3 -> a3 -> a3
forall a. Num a => a -> a -> a
+ a3
b3, a4
a4 a4 -> a4 -> a4
forall a. Num a => a -> a -> a
+ a4
b4, a5
a5 a5 -> a5 -> a5
forall a. Num a => a -> a -> a
+ a5
b5, a6
a6 a6 -> a6 -> a6
forall a. Num a => a -> a -> a
+ a6
b6, a7
a7 a7 -> a7 -> a7
forall a. Num a => a -> a -> a
+ a7
b7, a8
a8 a8 -> a8 -> a8
forall a. Num a => a -> a -> a
+ a8
b8)
(a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) * :: (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
* (a1
b1, a2
b2, a3
b3, a4
b4, a5
b5, a6
b6, a7
b7, a8
b8) = (a1
a1 a1 -> a1 -> a1
forall a. Num a => a -> a -> a
* a1
b1, a2
a2 a2 -> a2 -> a2
forall a. Num a => a -> a -> a
* a2
b2, a3
a3 a3 -> a3 -> a3
forall a. Num a => a -> a -> a
* a3
b3, a4
a4 a4 -> a4 -> a4
forall a. Num a => a -> a -> a
* a4
b4, a5
a5 a5 -> a5 -> a5
forall a. Num a => a -> a -> a
* a5
b5, a6
a6 a6 -> a6 -> a6
forall a. Num a => a -> a -> a
* a6
b6, a7
a7 a7 -> a7 -> a7
forall a. Num a => a -> a -> a
+ a7
b7, a8
a8 a8 -> a8 -> a8
forall a. Num a => a -> a -> a
+ a8
b8)
negate :: (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
negate (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) = (a1 -> a1
forall a. Num a => a -> a
negate a1
a1, a2 -> a2
forall a. Num a => a -> a
negate a2
a2, a3 -> a3
forall a. Num a => a -> a
negate a3
a3, a4 -> a4
forall a. Num a => a -> a
negate a4
a4, a5 -> a5
forall a. Num a => a -> a
negate a5
a5, a6 -> a6
forall a. Num a => a -> a
negate a6
a6, a7 -> a7
forall a. Num a => a -> a
negate a7
a7, a8 -> a8
forall a. Num a => a -> a
negate a8
a8)
fromInteger :: Integer -> (a1, a2, a3, a4, a5, a6, a7, a8)
fromInteger Integer
n = (Integer -> a1
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a2
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a3
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a4
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a5
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a6
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a7
forall a. Num a => Integer -> a
fromInteger Integer
n, Integer -> a8
forall a. Num a => Integer -> a
fromInteger Integer
n)
signum :: (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
signum (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) = (a1 -> a1
forall a. Num a => a -> a
signum a1
a1, a2 -> a2
forall a. Num a => a -> a
signum a2
a2, a3 -> a3
forall a. Num a => a -> a
signum a3
a3, a4 -> a4
forall a. Num a => a -> a
signum a4
a4, a5 -> a5
forall a. Num a => a -> a
signum a5
a5, a6 -> a6
forall a. Num a => a -> a
signum a6
a6, a7 -> a7
forall a. Num a => a -> a
signum a7
a7, a8 -> a8
forall a. Num a => a -> a
signum a8
a8)
abs :: (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
abs (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) = (a1 -> a1
forall a. Num a => a -> a
abs a1
a1, a2 -> a2
forall a. Num a => a -> a
abs a2
a2, a3 -> a3
forall a. Num a => a -> a
abs a3
a3, a4 -> a4
forall a. Num a => a -> a
abs a4
a4, a5 -> a5
forall a. Num a => a -> a
abs a5
a5, a6 -> a6
forall a. Num a => a -> a
abs a6
a6, a7 -> a7
forall a. Num a => a -> a
abs a7
a7, a8 -> a8
forall a. Num a => a -> a
abs a8
a8)
instance (Fractional a1, Fractional a2, Fractional a3, Fractional a4, Fractional a5, Fractional a6, Fractional a7, Fractional a8) => Fractional (a1, a2, a3, a4, a5, a6, a7, a8) where
recip :: (a1, a2, a3, a4, a5, a6, a7, a8)
-> (a1, a2, a3, a4, a5, a6, a7, a8)
recip (a1
a1, a2
a2, a3
a3, a4
a4, a5
a5, a6
a6, a7
a7, a8
a8) = (a1 -> a1
forall a. Fractional a => a -> a
recip a1
a1, a2 -> a2
forall a. Fractional a => a -> a
recip a2
a2, a3 -> a3
forall a. Fractional a => a -> a
recip a3
a3, a4 -> a4
forall a. Fractional a => a -> a
recip a4
a4, a5 -> a5
forall a. Fractional a => a -> a
recip a5
a5, a6 -> a6
forall a. Fractional a => a -> a
recip a6
a6, a7 -> a7
forall a. Fractional a => a -> a
recip a7
a7, a8 -> a8
forall a. Fractional a => a -> a
recip a8
a8)
fromRational :: Rational -> (a1, a2, a3, a4, a5, a6, a7, a8)
fromRational Rational
n = (Rational -> a1
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a2
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a3
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a4
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a5
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a6
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a7
forall a. Fractional a => Rational -> a
fromRational Rational
n, Rational -> a8
forall a. Fractional a => Rational -> a
fromRational Rational
n)