module HordeAd.Core.AstPrettyPrint
( PrintConfig(..), defaulPrintConfig
, printAstVar, printAst
) where
import Prelude
import Data.Foldable qualified as Foldable
import Data.IntMap.Strict (IntMap)
import Data.IntMap.Strict qualified as IM
import Data.List (intersperse)
import Data.Proxy (Proxy (Proxy))
import Data.Type.Equality ((:~:) (Refl))
import Data.Vector.Generic qualified as V
import Data.Array.Nested qualified as Nested
import Data.Array.Nested.Permutation (Perm (..), permToList)
import Data.Array.Nested.Shaped.Shape
import HordeAd.Core.Ast
import HordeAd.Core.AstTools
import HordeAd.Core.TensorKind
import HordeAd.Core.Types
data PrintConfig = PrintConfig
{ PrintConfig -> Bool
loseRoudtrip :: Bool
, PrintConfig -> Bool
ignoreNestedLambdas :: Bool
, PrintConfig -> IntMap String
varRenames :: IntMap String
}
defaulPrintConfig :: PrintConfig
defaulPrintConfig :: PrintConfig
defaulPrintConfig = PrintConfig
{ loseRoudtrip :: Bool
loseRoudtrip = Bool
True
, ignoreNestedLambdas :: Bool
ignoreNestedLambdas = Bool
True
, varRenames :: IntMap String
varRenames = IntMap String
forall a. IntMap a
IM.empty
}
printAstVarId :: String -> PrintConfig -> AstVarId -> ShowS
printAstVarId :: String -> PrintConfig -> AstVarId -> ShowS
printAstVarId String
prefix PrintConfig
cfg AstVarId
var =
let n :: Int
n = AstVarId -> Int
forall a. Enum a => a -> Int
fromEnum AstVarId
var Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
100000000
in String -> ShowS
showString (String -> ShowS) -> String -> ShowS
forall a b. (a -> b) -> a -> b
$ case Int -> IntMap String -> Maybe String
forall a. Int -> IntMap a -> Maybe a
IM.lookup Int
n (PrintConfig -> IntMap String
varRenames PrintConfig
cfg) of
Just String
name | String
name String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
"" -> String
name
Maybe String
_ -> String
prefix String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n
printAstVar :: forall s y. AstSpan s
=> PrintConfig -> AstVarName s y -> ShowS
printAstVar :: forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s y
var = case Proxy @AstSpanType s
-> FullShapeTK y
-> Maybe
((:~:)
@Type
(AstTensor (ZonkAny @AstMethodOfSharing 0) s y)
(AstInt (ZonkAny @AstMethodOfSharing 0)))
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
Proxy @AstSpanType s
-> FullShapeTK y
-> Maybe ((:~:) @Type (AstTensor ms s y) (AstInt ms))
isTensorInt (forall {k} (t :: k). Proxy @k t
forall (t :: AstSpanType). Proxy @AstSpanType t
Proxy @s) (AstVarName s y -> FullShapeTK y
forall (s :: AstSpanType) (y :: TK).
AstVarName s y -> FullShapeTK y
varNameToFTK AstVarName s y
var) of
Just (:~:)
@Type
(AstTensor (ZonkAny @AstMethodOfSharing 0) s y)
(AstInt (ZonkAny @AstMethodOfSharing 0))
Refl -> PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg AstVarName s y
IntVarName
var
Maybe
((:~:)
@Type
(AstTensor (ZonkAny @AstMethodOfSharing 0) s y)
(AstInt (ZonkAny @AstMethodOfSharing 0)))
_ -> let prefix :: String
prefix = case SingletonTK y -> Int
forall (x :: TK). SingletonTK x -> Int
lengthSTK (FullShapeTK y -> SingletonTK y
forall (y :: TK). FullShapeTK y -> SingletonTK y
ftkToSTK (FullShapeTK y -> SingletonTK y) -> FullShapeTK y -> SingletonTK y
forall a b. (a -> b) -> a -> b
$ AstVarName s y -> FullShapeTK y
forall (s :: AstSpanType) (y :: TK).
AstVarName s y -> FullShapeTK y
varNameToFTK AstVarName s y
var) of
Int
0 -> String
"x"
Int
1 -> String
"v"
Int
2 -> String
"m"
Int
3 -> String
"t"
Int
4 -> String
"u"
Int
_ -> String
"w"
in String -> PrintConfig -> AstVarId -> ShowS
printAstVarId String
prefix PrintConfig
cfg (AstVarName s y -> AstVarId
forall (s :: AstSpanType) (y :: TK). AstVarName s y -> AstVarId
varNameToAstVarId AstVarName s y
var)
printAstIntVar :: PrintConfig -> IntVarName -> ShowS
printAstIntVar :: PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg IntVarName
var = String -> PrintConfig -> AstVarId -> ShowS
printAstVarId String
"i" PrintConfig
cfg (IntVarName -> AstVarId
forall (s :: AstSpanType) (y :: TK). AstVarName s y -> AstVarId
varNameToAstVarId IntVarName
var)
printAst :: forall s y ms. AstSpan s
=> PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst :: forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d = \case
AstPair AstTensor ms s y
t1 AstTensor ms s z
t2 ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tpair "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s y
t1
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s z -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s z
t2
AstProject1 AstTensor ms s (TKProduct y z)
t -> (PrintConfig -> Int -> AstTensor ms s (TKProduct y z) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKProduct y z)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKProduct y z) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tproject1" [AstTensor ms s (TKProduct y z)
t]
AstProject2 AstTensor ms s (TKProduct y y)
t -> (PrintConfig -> Int -> AstTensor ms s (TKProduct y y) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKProduct y y)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKProduct y y) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tproject2" [AstTensor ms s (TKProduct y y)
t]
AstFromVector SNat k
snat SingletonTK y
stk Vector (AstTensor ms s y)
l ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then case SingletonTK y
stk of
STKR{} ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"rfromVector "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"fromList "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms s y -> ShowS) -> [AstTensor ms s y] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (Vector (AstTensor ms s y) -> [AstTensor ms s y]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
V.toList Vector (AstTensor ms s y)
l))
STKS{} ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"sfromVector "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"fromList "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms s y -> ShowS) -> [AstTensor ms s y] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (Vector (AstTensor ms s y) -> [AstTensor ms s y]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
V.toList Vector (AstTensor ms s y)
l))
STKX{} ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"xfromVector "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"fromList "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms s y -> ShowS) -> [AstTensor ms s y] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (Vector (AstTensor ms s y) -> [AstTensor ms s y]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
V.toList Vector (AstTensor ms s y)
l))
SingletonTK y
_ ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tfromVector "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"fromList "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms s y -> ShowS) -> [AstTensor ms s y] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (Vector (AstTensor ms s y) -> [AstTensor ms s y]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
V.toList Vector (AstTensor ms s y)
l))
else Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString (String
"tfromVector (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SNat k -> String
forall a. Show a => a -> String
show SNat k
snat String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SingletonTK y -> String
forall a. Show a => a -> String
show SingletonTK y
stk String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") ")
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"fromList "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms s y -> ShowS) -> [AstTensor ms s y] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (Vector (AstTensor ms s y) -> [AstTensor ms s y]
forall (v :: Type -> Type) a. Vector v a => v a -> [a]
V.toList Vector (AstTensor ms s y)
l))
AstSum SNat k
snat SingletonTK y
stk AstTensor ms s (BuildTensorKind k y)
v -> case SingletonTK y
stk of
STKR{} -> (PrintConfig -> Int -> AstTensor ms s (TKR2 (1 + n) x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKR2 (1 + n) x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKR2 (1 + n) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"rsum" [AstTensor ms s (BuildTensorKind k y)
AstTensor ms s (TKR2 (1 + n) x)
v]
STKS{} -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 ((':) @Nat k sh) x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 ((':) @Nat k sh) x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int -> AstTensor ms s (TKS2 ((':) @Nat k sh) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"ssum @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (SNat k -> Int
forall (n :: Nat). SNat n -> Int
sNatValue SNat k
snat)) [AstTensor ms s (BuildTensorKind k y)
AstTensor ms s (TKS2 ((':) @Nat k sh) x)
v]
STKX{} -> (PrintConfig
-> Int
-> AstTensor ms s (TKX2 ((':) @(Maybe Nat) ('Just @Nat k) sh) x)
-> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKX2 ((':) @(Maybe Nat) ('Just @Nat k) sh) x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int
-> AstTensor ms s (TKX2 ((':) @(Maybe Nat) ('Just @Nat k) sh) x)
-> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"xsum @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (SNat k -> Int
forall (n :: Nat). SNat n -> Int
sNatValue SNat k
snat)) [AstTensor ms s (BuildTensorKind k y)
AstTensor ms s (TKX2 ((':) @(Maybe Nat) ('Just @Nat k) sh) x)
v]
SingletonTK y
_ ->
(PrintConfig
-> Int -> AstTensor ms s (BuildTensorKind k y) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (BuildTensorKind k y)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (BuildTensorKind k y) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"tsum (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SNat k -> String
forall a. Show a => a -> String
show SNat k
snat String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SingletonTK y -> String
forall a. Show a => a -> String
show SingletonTK y
stk String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")") [AstTensor ms s (BuildTensorKind k y)
v]
AstReplicate SNat k
snat SingletonTK y
stk AstTensor ms s y
v -> case SingletonTK y
stk of
STKR{} -> (PrintConfig -> Int -> AstTensor ms s y -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s y] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"rreplicate " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (SNat k -> Int
forall (n :: Nat). SNat n -> Int
sNatValue SNat k
snat)) [AstTensor ms s y
v]
STKS{} -> (PrintConfig -> Int -> AstTensor ms s y -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s y] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"sreplicate @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (SNat k -> Int
forall (n :: Nat). SNat n -> Int
sNatValue SNat k
snat)) [AstTensor ms s y
v]
STKX{} -> (PrintConfig -> Int -> AstTensor ms s y -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s y] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"xreplicate @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (SNat k -> Int
forall (n :: Nat). SNat n -> Int
sNatValue SNat k
snat)) [AstTensor ms s y
v]
SingletonTK y
_ ->
(PrintConfig -> Int -> AstTensor ms s y -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s y] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp
PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"treplicate (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SNat k -> String
forall a. Show a => a -> String
show SNat k
snat String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SingletonTK y -> String
forall a. Show a => a -> String
show SingletonTK y
stk String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")") [AstTensor ms s y
v]
AstMapAccumRDer SNat k
k FullShapeTK by
bftk FullShapeTK ey
eftk AstHFun s s (TKProduct accy ey) (TKProduct accy by)
f AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy ey)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy by))
df AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy by)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy ey))
rf AstTensor ms s accy
acc0 AstTensor ms s (BuildTensorKind k ey)
es ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tmapAccumRDer "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (SNat k -> ShowS
forall a. Show a => a -> ShowS
shows SNat k
k)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun s s (TKProduct accy ey) (TKProduct accy by)
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun s s (TKProduct accy ey) (TKProduct accy by)
f
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy ey)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy by))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
df
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy by)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy ey))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
rf
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s accy -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s accy
acc0
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (BuildTensorKind k ey) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (BuildTensorKind k ey)
es
else
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tmapAccumRDer "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (SNat k -> ShowS
forall a. Show a => a -> ShowS
shows SNat k
k)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (FullShapeTK by -> ShowS
forall a. Show a => a -> ShowS
shows FullShapeTK by
bftk)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (FullShapeTK ey -> ShowS
forall a. Show a => a -> ShowS
shows FullShapeTK ey
eftk)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun s s (TKProduct accy ey) (TKProduct accy by)
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun s s (TKProduct accy ey) (TKProduct accy by)
f
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy ey)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy by))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
df
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy by)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy ey))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
rf
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s accy -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s accy
acc0
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (BuildTensorKind k ey) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (BuildTensorKind k ey)
es
AstMapAccumLDer SNat k
k FullShapeTK by
bftk FullShapeTK ey
eftk AstHFun s s (TKProduct accy ey) (TKProduct accy by)
f AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy ey)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy by))
df AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy by)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy ey))
rf AstTensor ms s accy
acc0 AstTensor ms s (BuildTensorKind k ey)
es ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tmapAccumLDer "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (SNat k -> ShowS
forall a. Show a => a -> ShowS
shows SNat k
k)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun s s (TKProduct accy ey) (TKProduct accy by)
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun s s (TKProduct accy ey) (TKProduct accy by)
f
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy ey)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy by))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
df
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy by)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy ey))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
rf
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s accy -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s accy
acc0
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (BuildTensorKind k ey) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (BuildTensorKind k ey)
es
else
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tmapAccumLDer "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (SNat k -> ShowS
forall a. Show a => a -> ShowS
shows SNat k
k)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (FullShapeTK by -> ShowS
forall a. Show a => a -> ShowS
shows FullShapeTK by
bftk)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (FullShapeTK ey -> ShowS
forall a. Show a => a -> ShowS
shows FullShapeTK ey
eftk)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun s s (TKProduct accy ey) (TKProduct accy by)
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun s s (TKProduct accy ey) (TKProduct accy by)
f
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy ey)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy by))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind by))
df
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
-> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
10 AstHFun
s
s
(TKProduct (ADTensorKind (TKProduct accy by)) (TKProduct accy ey))
(ADTensorKind (TKProduct accy ey))
AstHFun
s
s
(TKProduct
(TKProduct (ADTensorKind accy) (ADTensorKind by))
(TKProduct accy ey))
(TKProduct (ADTensorKind accy) (ADTensorKind ey))
rf
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s accy -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s accy
acc0
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (BuildTensorKind k ey) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (BuildTensorKind k ey)
es
AstApply AstHFun s1 s x y
t AstTensor ms s1 x
ll -> Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tApply "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstHFun s1 s x y -> ShowS
forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFunOneUnignore PrintConfig
cfg Int
10 AstHFun s1 s x y
t
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s1 x -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s1 x
ll
AstVar AstVarName s y
var -> PrintConfig -> AstVarName s y -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s y
var
AstCond AstBool ms
b AstTensor ms s y
a1 AstTensor ms s y
a2 ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"ifH "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstBool ms -> ShowS
forall (ms :: AstMethodOfSharing).
PrintConfig -> Int -> AstBool ms -> ShowS
printAstBool PrintConfig
cfg Int
11 AstBool ms
b
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s y
a1
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s y
a2
AstBuild1 SNat k
k SingletonTK y
stk (IntVarName
var, AstTensor ms s y
v) ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tbuild1 ("
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SNat k -> ShowS
forall a. Show a => a -> ShowS
shows SNat k
k
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
") "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg IntVarName
var
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor ms s y
v)
else
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tbuild1 ("
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SNat k -> ShowS
forall a. Show a => a -> ShowS
shows SNat k
k
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
") "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ShowS -> ShowS
showParen Bool
True (SingletonTK y -> ShowS
forall a. Show a => a -> ShowS
shows SingletonTK y
stk)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg IntVarName
var
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor ms s y
v)
t :: AstTensor ms s y
t@(AstLet @_ @_ @s1 AstVarName s y
var0 AstTensor AstMethodLet s y
u0 AstTensor AstMethodLet s y
v0) ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then let collect :: AstTensor AstMethodLet s y -> ([(ShowS, ShowS)], ShowS)
collect :: AstTensor AstMethodLet s y -> ([(ShowS, ShowS)], ShowS)
collect (AstLet AstVarName s y
var AstTensor AstMethodLet s y
u AstTensor AstMethodLet s y
v) =
let name :: ShowS
name = PrintConfig -> AstVarName s y -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s y
var
uPP :: ShowS
uPP = PrintConfig -> Int -> AstTensor AstMethodLet s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s y
u
([(ShowS, ShowS)]
rest, ShowS
corePP) = AstTensor AstMethodLet s y -> ([(ShowS, ShowS)], ShowS)
collect AstTensor AstMethodLet s y
v
in ((ShowS
name, ShowS
uPP) (ShowS, ShowS) -> [(ShowS, ShowS)] -> [(ShowS, ShowS)]
forall a. a -> [a] -> [a]
: [(ShowS, ShowS)]
rest, ShowS
corePP)
collect AstTensor AstMethodLet s y
v = ([], PrintConfig -> Int -> AstTensor AstMethodLet s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s y
v)
([(ShowS, ShowS)]
pairs, ShowS
core) = AstTensor AstMethodLet s y -> ([(ShowS, ShowS)], ShowS)
collect AstTensor ms s y
AstTensor AstMethodLet s y
t
in Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"let "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShowS -> ShowS -> ShowS) -> ShowS -> [ShowS] -> ShowS
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: Type -> Type) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) ShowS
forall a. a -> a
id (ShowS -> [ShowS] -> [ShowS]
forall a. a -> [a] -> [a]
intersperse (String -> ShowS
showString String
" ; ")
[ShowS
name ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" = " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
uPP | (ShowS
name, ShowS
uPP) <- [(ShowS, ShowS)]
pairs])
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" in "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
core
else let keyword :: String
keyword = case ( forall (s1 :: AstSpanType) (s2 :: AstSpanType).
(AstSpan s1, AstSpan s2) =>
Maybe ((:~:) @AstSpanType s1 s2)
sameAstSpan @s1 @PrimalSpan
, forall (s1 :: AstSpanType) (s2 :: AstSpanType).
(AstSpan s1, AstSpan s2) =>
Maybe ((:~:) @AstSpanType s1 s2)
sameAstSpan @s @FullSpan ) of
(Just (:~:) @AstSpanType s PrimalSpan
Refl, Just (:~:) @AstSpanType s FullSpan
Refl) -> String
"ttletPrimal "
(Maybe ((:~:) @AstSpanType s PrimalSpan),
Maybe ((:~:) @AstSpanType s FullSpan))
_ -> String
"tlet "
in Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
keyword
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor AstMethodLet s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor AstMethodLet s y
u0
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> AstVarName s y -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s y
var0
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor AstMethodLet s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s y
v0)
AstShare AstVarName s y
_var AstTensor AstMethodShare s y
v -> (PrintConfig -> Int -> AstTensor AstMethodShare s y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor AstMethodShare s y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor AstMethodShare s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tshare" [AstTensor AstMethodShare s y
v]
AstToShare AstTensor AstMethodLet s y
v -> (PrintConfig -> Int -> AstTensor AstMethodLet s y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor AstMethodLet s y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor AstMethodLet s y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"toShare" [AstTensor AstMethodLet s y
v]
AstPrimalPart AstTensor ms FullSpan y
a ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then case AstTensor ms FullSpan y -> FullShapeTK y
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstTensor ms s y -> FullShapeTK y
ftkAst AstTensor ms FullSpan y
a of
FTKR{} -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"rprimalPart" [AstTensor ms FullSpan y
a]
FTKS{} -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sprimalPart" [AstTensor ms FullSpan y
a]
FTKX{} -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"xprimalPart" [AstTensor ms FullSpan y
a]
FullShapeTK y
_ -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tprimalPart" [AstTensor ms FullSpan y
a]
else (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tprimalPart" [AstTensor ms FullSpan y
a]
AstDualPart AstTensor ms FullSpan y
a ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then case AstTensor ms FullSpan y -> FullShapeTK y
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstTensor ms s y -> FullShapeTK y
ftkAst AstTensor ms FullSpan y
a of
FTKR{} -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"rdualPart" [AstTensor ms FullSpan y
a]
FTKS{} -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sdualPart" [AstTensor ms FullSpan y
a]
FTKX{} -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"xdualPart" [AstTensor ms FullSpan y
a]
FullShapeTK y
_ -> (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tdualPart" [AstTensor ms FullSpan y
a]
else (PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms FullSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms FullSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"tdualPart (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SingletonTK y -> String
forall a. Show a => a -> String
show (FullShapeTK y -> SingletonTK y
forall (y :: TK). FullShapeTK y -> SingletonTK y
ftkToSTK (AstTensor ms FullSpan y -> FullShapeTK y
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstTensor ms s y -> FullShapeTK y
ftkAst AstTensor ms FullSpan y
a)) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")") [AstTensor ms FullSpan y
a]
AstFromPrimal AstTensor ms PrimalSpan y
a ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then PrintConfig -> Int -> AstTensor ms PrimalSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms PrimalSpan y
a
else (PrintConfig -> Int -> AstTensor ms PrimalSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp
PrintConfig -> Int -> AstTensor ms PrimalSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"tfromPrimal (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SingletonTK y -> String
forall a. Show a => a -> String
show (FullShapeTK y -> SingletonTK y
forall (y :: TK). FullShapeTK y -> SingletonTK y
ftkToSTK (AstTensor ms PrimalSpan y -> FullShapeTK y
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstTensor ms s y -> FullShapeTK y
ftkAst AstTensor ms PrimalSpan y
a)) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")") [AstTensor ms PrimalSpan y
a]
AstFromDual AstTensor ms DualSpan y
a ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then PrintConfig -> Int -> AstTensor ms DualSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms DualSpan y
a
else (PrintConfig -> Int -> AstTensor ms DualSpan y -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms DualSpan y]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms DualSpan y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"tfromDual" [AstTensor ms DualSpan y
a]
AstPlusK AstTensor ms s (TKScalar r)
u AstTensor ms s (TKScalar r)
v -> (PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> AstTensor ms s (TKScalar r)
-> (Int, String)
-> AstTensor ms s (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms s (TKScalar r)
u (Int
6, String
"+") AstTensor ms s (TKScalar r)
v
AstTimesK AstTensor ms s (TKScalar r)
u AstTensor ms s (TKScalar r)
v -> (PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> AstTensor ms s (TKScalar r)
-> (Int, String)
-> AstTensor ms s (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms s (TKScalar r)
u (Int
7, String
"*") AstTensor ms s (TKScalar r)
v
AstN1K OpCodeNum1
opCode AstTensor ms s (TKScalar r)
u -> (PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> OpCodeNum1
-> AstTensor ms s (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeNum1 -> a -> ShowS
printAstN1R PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCodeNum1
opCode AstTensor ms s (TKScalar r)
u
AstR1K OpCode1
opCode AstTensor ms s (TKScalar r)
u -> (PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> OpCode1
-> AstTensor ms s (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode1 -> a -> ShowS
printAstR1R PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCode1
opCode AstTensor ms s (TKScalar r)
u
AstR2K OpCode2
opCode AstTensor ms s (TKScalar r)
u AstTensor ms s (TKScalar r)
v -> (PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> OpCode2
-> AstTensor ms s (TKScalar r)
-> AstTensor ms s (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode2 -> a -> a -> ShowS
printAstR2R PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCode2
opCode AstTensor ms s (TKScalar r)
u AstTensor ms s (TKScalar r)
v
AstI2K OpCodeIntegral2
opCode AstTensor ms s (TKScalar r)
u AstTensor ms s (TKScalar r)
v -> (PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> OpCodeIntegral2
-> AstTensor ms s (TKScalar r)
-> AstTensor ms s (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeIntegral2 -> a -> a -> ShowS
printAstI2R PrintConfig -> Int -> AstTensor ms s (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCodeIntegral2
opCode AstTensor ms s (TKScalar r)
u AstTensor ms s (TKScalar r)
v
AstConcreteK r
k -> r -> ShowS
forall a. (Ord a, Num a, Show a) => a -> ShowS
showNumber r
k
AstFloorK AstTensor ms PrimalSpan (TKScalar r1)
v ->
(PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar r1) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan (TKScalar r1)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar r1) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"kfloor" [AstTensor ms PrimalSpan (TKScalar r1)
v]
AstFromIntegralK AstTensor ms PrimalSpan (TKScalar r1)
v ->
(PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar r1) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan (TKScalar r1)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar r1) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"kfromIntegral" [AstTensor ms PrimalSpan (TKScalar r1)
v]
AstCastK AstTensor ms s (TKScalar r1)
v ->
(PrintConfig -> Int -> AstTensor ms s (TKScalar r1) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKScalar r1)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKScalar r1) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"kcast" [AstTensor ms s (TKScalar r1)
v]
AstPlusS AstTensor ms s (TKS2 sh (TKScalar r))
u AstTensor ms s (TKS2 sh (TKScalar r))
v -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS)
-> PrintConfig
-> Int
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> (Int, String)
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms s (TKS2 sh (TKScalar r))
u (Int
6, String
"+") AstTensor ms s (TKS2 sh (TKScalar r))
v
AstTimesS AstTensor ms s (TKS2 sh (TKScalar r))
u AstTensor ms s (TKS2 sh (TKScalar r))
v -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS)
-> PrintConfig
-> Int
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> (Int, String)
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms s (TKS2 sh (TKScalar r))
u (Int
7, String
"*") AstTensor ms s (TKS2 sh (TKScalar r))
v
AstN1S OpCodeNum1
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS)
-> PrintConfig
-> Int
-> OpCodeNum1
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeNum1 -> a -> ShowS
printAstN1R PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCodeNum1
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u
AstR1S OpCode1
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS)
-> PrintConfig
-> Int
-> OpCode1
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode1 -> a -> ShowS
printAstR1R PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCode1
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u
AstR2S OpCode2
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u AstTensor ms s (TKS2 sh (TKScalar r))
v -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS)
-> PrintConfig
-> Int
-> OpCode2
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode2 -> a -> a -> ShowS
printAstR2R PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCode2
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u AstTensor ms s (TKS2 sh (TKScalar r))
v
AstI2S OpCodeIntegral2
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u AstTensor ms s (TKS2 sh (TKScalar r))
v -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS)
-> PrintConfig
-> Int
-> OpCodeIntegral2
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> AstTensor ms s (TKS2 sh (TKScalar r))
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeIntegral2 -> a -> a -> ShowS
printAstI2R PrintConfig
-> Int -> AstTensor ms s (TKS2 sh (TKScalar r)) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d OpCodeIntegral2
opCode AstTensor ms s (TKS2 sh (TKScalar r))
u AstTensor ms s (TKS2 sh (TKScalar r))
v
AstConcreteS Shaped sh r
a -> case Shaped sh r -> ShS sh
forall (sh :: [Nat]) a. Elt a => Shaped sh a -> ShS sh
Nested.sshape Shaped sh r
a of
ShS sh
ZSS -> Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"sscalar "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> ShowS
forall a. (Ord a, Num a, Show a) => a -> ShowS
showNumber (Shaped ('[] @Nat) r -> r
forall a. Elt a => Shaped ('[] @Nat) a -> a
Nested.sunScalar Shaped sh r
Shaped ('[] @Nat) r
a)
ShS sh
_ -> Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"sconcrete "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Shaped sh r -> ShowS
forall a. Show a => a -> ShowS
shows Shaped sh r
a)
AstFloorS AstTensor ms PrimalSpan (TKS sh r1)
a ->
(PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKS sh r1) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan (TKS sh r1)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms PrimalSpan (TKS sh r1) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sfloor" [AstTensor ms PrimalSpan (TKS sh r1)
a]
AstFromIntegralS AstTensor ms PrimalSpan (TKS sh r1)
a ->
(PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKS sh r1) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan (TKS sh r1)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms PrimalSpan (TKS sh r1) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sfromIntegral" [AstTensor ms PrimalSpan (TKS sh r1)
a]
AstCastS AstTensor ms s (TKS sh r1)
a ->
(PrintConfig -> Int -> AstTensor ms s (TKS sh r1) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS sh r1)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKS sh r1) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"scast" [AstTensor ms s (TKS sh r1)
a]
AstIndexS ShS shn
_ AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v AstIxS ms shm
ix ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
9)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ PrintConfig
-> Int -> AstTensor ms s (TKS2 ((++) @Nat shm shn) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
10 AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" !$ "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS)
-> [AstTensor ms PrimalSpan (TKScalar Int64)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (AstIxS ms shm -> [AstTensor ms PrimalSpan (TKScalar Int64)]
forall a. IxS shm a -> [a]
forall (t :: Type -> Type) a. Foldable t => t a -> [a]
Foldable.toList AstIxS ms shm
ix)
AstScatterS ShS shn
_ AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v (AstVarListS shm
ZS, AstIxS ms shp
ix) ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
9)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"soneHot "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor ms s (TKS2 shn x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 shn x)
AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS)
-> [AstTensor ms PrimalSpan (TKScalar Int64)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (AstIxS ms shp -> [AstTensor ms PrimalSpan (TKScalar Int64)]
forall a. IxS shp a -> [a]
forall (t :: Type -> Type) a. Foldable t => t a -> [a]
Foldable.toList AstIxS ms shp
ix)
AstScatterS ShS shn
sh AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v (AstVarListS shm
vars, AstIxS ms shp
ix) ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"sscatter "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (TKS2 ((++) @Nat shm shn) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IntVarName -> ShowS) -> [IntVarName] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg)
(AstVarListS shm -> [IntVarName]
forall (sh :: [Nat]) i. ListS sh (Const @Nat i) -> [i]
listsToList AstVarListS shm
vars)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS)
-> [AstTensor ms PrimalSpan (TKScalar Int64)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (AstIxS ms shp -> [AstTensor ms PrimalSpan (TKScalar Int64)]
forall a. IxS shp a -> [a]
forall (t :: Type -> Type) a. Foldable t => t a -> [a]
Foldable.toList AstIxS ms shp
ix))
else
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString (String
"sscatter " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShS shn -> String
forall a. Show a => a -> String
show ShS shn
sh String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" ")
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (TKS2 ((++) @Nat shm shn) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 ((++) @Nat shm shn) x)
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IntVarName -> ShowS) -> [IntVarName] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg)
(AstVarListS shm -> [IntVarName]
forall (sh :: [Nat]) i. ListS sh (Const @Nat i) -> [i]
listsToList AstVarListS shm
vars)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS)
-> [AstTensor ms PrimalSpan (TKScalar Int64)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (AstIxS ms shp -> [AstTensor ms PrimalSpan (TKScalar Int64)]
forall a. IxS shp a -> [a]
forall (t :: Type -> Type) a. Foldable t => t a -> [a]
Foldable.toList AstIxS ms shp
ix))
AstGatherS ShS shn
sh AstTensor ms s (TKS2 ((++) @Nat shp shn) x)
v (AstVarListS shm
vars, AstIxS ms shp
ix) ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"sgather "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (TKS2 ((++) @Nat shp shn) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 ((++) @Nat shp shn) x)
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IntVarName -> ShowS) -> [IntVarName] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg)
(AstVarListS shm -> [IntVarName]
forall (sh :: [Nat]) i. ListS sh (Const @Nat i) -> [i]
listsToList AstVarListS shm
vars)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS)
-> [AstTensor ms PrimalSpan (TKScalar Int64)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (AstIxS ms shp -> [AstTensor ms PrimalSpan (TKScalar Int64)]
forall a. IxS shp a -> [a]
forall (t :: Type -> Type) a. Foldable t => t a -> [a]
Foldable.toList AstIxS ms shp
ix))
else
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString (String
"sgather " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShS shn -> String
forall a. Show a => a -> String
show ShS shn
sh String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" ")
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (TKS2 ((++) @Nat shp shn) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 ((++) @Nat shp shn) x)
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
showParen Bool
True
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IntVarName -> ShowS) -> [IntVarName] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig -> IntVarName -> ShowS
printAstIntVar PrintConfig
cfg)
(AstVarListS shm -> [IntVarName]
forall (sh :: [Nat]) i. ListS sh (Const @Nat i) -> [i]
listsToList AstVarListS shm
vars)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS)
-> [AstTensor ms PrimalSpan (TKScalar Int64)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar Int64) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0) (AstIxS ms shp -> [AstTensor ms PrimalSpan (TKScalar Int64)]
forall a. IxS shp a -> [a]
forall (t :: Type -> Type) a. Foldable t => t a -> [a]
Foldable.toList AstIxS ms shp
ix))
AstMinIndexS AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)
a -> (PrintConfig
-> Int
-> AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)
-> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sminIndex" [AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)
a]
AstMaxIndexS AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)
a -> (PrintConfig
-> Int
-> AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)
-> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"smaxIndex" [AstTensor ms PrimalSpan (TKS ((':) @Nat n sh) r)
a]
AstIotaS SNat n
snat ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString (String
"siota (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SNat n -> String
forall a. Show a => a -> String
show SNat n
snat String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")")
AstAppendS AstTensor ms s (TKS2 ((':) @Nat m sh) x)
t1 AstTensor ms s (TKS2 ((':) @Nat n sh) x)
t2 ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"sappend "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (TKS2 ((':) @Nat m sh) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 ((':) @Nat m sh) x)
t1
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int -> AstTensor ms s (TKS2 ((':) @Nat n sh) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS2 ((':) @Nat n sh) x)
t2
AstSliceS SNat i
i SNat n
n SNat k
_k AstTensor ms s (TKS2 ((':) @Nat ((i + n) + k) sh) x)
v ->
(PrintConfig
-> Int
-> AstTensor ms s (TKS2 ((':) @Nat ((i + n) + k) sh) x)
-> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 ((':) @Nat ((i + n) + k) sh) x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int
-> AstTensor ms s (TKS2 ((':) @Nat ((i + n) + k) sh) x)
-> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"sslice (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SNat i -> String
forall a. Show a => a -> String
show SNat i
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SNat n -> String
forall a. Show a => a -> String
show SNat n
n String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")") [AstTensor ms s (TKS2 ((':) @Nat ((i + n) + k) sh) x)
v]
AstReverseS AstTensor ms s (TKS2 ((':) @Nat n sh) x)
v -> (PrintConfig
-> Int -> AstTensor ms s (TKS2 ((':) @Nat n sh) x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 ((':) @Nat n sh) x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int -> AstTensor ms s (TKS2 ((':) @Nat n sh) x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sreverse" [AstTensor ms s (TKS2 ((':) @Nat n sh) x)
v]
AstTransposeS (SNat' @1 `PCons` SNat' @0 `PCons` Perm l
PNil) AstTensor ms s (TKS2 sh x)
v ->
(PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 sh x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"str" [AstTensor ms s (TKS2 sh x)
v]
AstTransposeS Perm perm
perm AstTensor ms s (TKS2 sh x)
v ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then (PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 sh x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"stranspose @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Nat] -> String
forall a. Show a => a -> String
show (Perm perm -> [Nat]
forall (list :: [Nat]). Perm list -> [Nat]
permToList Perm perm
perm)) [AstTensor ms s (TKS2 sh x)
v]
else (PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 sh x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp
PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d
(String
"ttranspose (makePerm @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Nat] -> String
forall a. Show a => a -> String
show (Perm perm -> [Nat]
forall (list :: [Nat]). Perm list -> [Nat]
permToList Perm perm
perm) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")") [AstTensor ms s (TKS2 sh x)
v]
AstReshapeS ShS sh2
sh2 AstTensor ms s (TKS2 sh x)
v ->
(PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 sh x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d (String
"sreshape @" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Int] -> String
forall a. Show a => a -> String
show (ShS sh2 -> [Int]
forall (sh :: [Nat]). ShS sh -> [Int]
shsToList ShS sh2
sh2)) [AstTensor ms s (TKS2 sh x)
v]
AstConvert TKConversion a1 y
c AstTensor ms s a1
t -> case (FullShapeTK a1 -> SingletonTK a1
forall (y :: TK). FullShapeTK y -> SingletonTK y
ftkToSTK (AstTensor ms s a1 -> FullShapeTK a1
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstTensor ms s y -> FullShapeTK y
ftkAst AstTensor ms s a1
t), TKConversion a1 y -> FullShapeTK a1 -> FullShapeTK y
forall (a :: TK) (b :: TK).
TKConversion a b -> FullShapeTK a -> FullShapeTK b
convertFTK TKConversion a1 y
c (AstTensor ms s a1 -> FullShapeTK a1
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstTensor ms s y -> FullShapeTK y
ftkAst AstTensor ms s a1
t)) of
(SingletonTK a1
STKScalar, FTKS{}) -> (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sfromK" [AstTensor ms s a1
t]
(STKR{}, FTKS{}) -> (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sfromR" [AstTensor ms s a1
t]
(STKX{}, FTKS{}) -> (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sfromX" [AstTensor ms s a1
t]
(STKS{}, FullShapeTK y
FTKScalar) -> (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"kfromS" [AstTensor ms s a1
t]
(STKS{}, FTKR{}) -> (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"rfromS" [AstTensor ms s a1
t]
(STKS{}, FTKX{}) -> (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"xfromS" [AstTensor ms s a1
t]
(SingletonTK a1
ystk, FullShapeTK y
_) -> let s :: String
s = String
"tconvert (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ TKConversion a1 y -> String
forall a. Show a => a -> String
show TKConversion a1 y
c String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SingletonTK a1 -> String
forall a. Show a => a -> String
show SingletonTK a1
ystk String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
in (PrintConfig -> Int -> AstTensor ms s a1 -> ShowS)
-> PrintConfig -> Int -> String -> [AstTensor ms s a1] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s a1 -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
s [AstTensor ms s a1
t]
AstSum0S AstTensor ms s (TKS2 sh x)
v ->
(PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS2 sh x)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKS2 sh x) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"ssum0" [AstTensor ms s (TKS2 sh x)
v]
AstDot0S AstTensor ms s (TKS sh r)
u AstTensor ms s (TKS sh r)
v ->
(PrintConfig -> Int -> AstTensor ms s (TKS sh r) -> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS sh r)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstTensor ms s (TKS sh r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sdot0" [AstTensor ms s (TKS sh r)
u, AstTensor ms s (TKS sh r)
v]
AstDot1InS ShS sh
_ SNat n
_ AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)
u AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)
v ->
(PrintConfig
-> Int
-> AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)
-> ShowS)
-> PrintConfig
-> Int
-> String
-> [AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)]
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig
-> Int
-> AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)
-> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d String
"sdot1In" [AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)
u, AstTensor ms s (TKS ((++) @Nat sh ((':) @Nat n ('[] @Nat))) r)
v]
AstMatmul2S SNat m
SNat SNat n
SNat SNat p
SNat AstTensor ms s (TKS ((':) @Nat m ((':) @Nat n ('[] @Nat))) r)
u AstTensor ms s (TKS ((':) @Nat n ((':) @Nat p ('[] @Nat))) r)
v ->
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"smatmul2 "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstTensor ms s (TKS ((':) @Nat m ((':) @Nat n ('[] @Nat))) r)
-> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS ((':) @Nat m ((':) @Nat n ('[] @Nat))) r)
u
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig
-> Int
-> AstTensor ms s (TKS ((':) @Nat n ((':) @Nat p ('[] @Nat))) r)
-> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
11 AstTensor ms s (TKS ((':) @Nat n ((':) @Nat p ('[] @Nat))) r)
v
showNumber :: (Ord a, Num a, Show a) => a -> ShowS
{-# INLINE showNumber #-}
showNumber :: forall a. (Ord a, Num a, Show a) => a -> ShowS
showNumber a
a = Bool -> ShowS -> ShowS
showParen (a
a a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ a -> ShowS
forall a. Show a => a -> ShowS
shows a
a
showListWith :: (a -> ShowS) -> [a] -> ShowS
{-# INLINE showListWith #-}
showListWith :: forall a. (a -> ShowS) -> [a] -> ShowS
showListWith = String -> String -> String -> (a -> ShowS) -> [a] -> ShowS
forall a.
String -> String -> String -> (a -> ShowS) -> [a] -> ShowS
showCollectionWith String
"[" String
", " String
"]"
showCollectionWith :: String -> String -> String -> (a -> ShowS) -> [a] -> ShowS
{-# INLINE showCollectionWith #-}
showCollectionWith :: forall a.
String -> String -> String -> (a -> ShowS) -> [a] -> ShowS
showCollectionWith String
start String
_ String
end a -> ShowS
_ [] String
s = String
start String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
end String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
showCollectionWith String
start String
sep String
end a -> ShowS
showx (a
x:[a]
xs) String
s = String
start String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> ShowS
showx a
x ([a] -> String
showl [a]
xs)
where
showl :: [a] -> String
showl [] = String
end String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
showl (a
y:[a]
ys) = String
sep String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> ShowS
showx a
y ([a] -> String
showl [a]
ys)
printAstHFun :: (AstSpan s, AstSpan s2)
=> PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun :: forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFun PrintConfig
cfg Int
d = \case
AstLambda AstVarName s x
var AstTensor AstMethodLet s2 y
l ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then if PrintConfig -> Bool
ignoreNestedLambdas PrintConfig
cfg
then String -> ShowS
showString String
"<lambda>"
else Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> AstVarName s x -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s x
var
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor AstMethodLet s2 y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s2 y
l
else Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tlambda $ \\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> AstVarName s x -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s x
var
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor AstMethodLet s2 y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s2 y
l
printAstHFunOneUnignore :: (AstSpan s, AstSpan s2)
=> PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFunOneUnignore :: forall (s :: AstSpanType) (s2 :: AstSpanType) (x :: TK) (y :: TK).
(AstSpan s, AstSpan s2) =>
PrintConfig -> Int -> AstHFun s s2 x y -> ShowS
printAstHFunOneUnignore PrintConfig
cfg Int
d = \case
AstLambda AstVarName s x
var AstTensor AstMethodLet s2 y
l ->
if PrintConfig -> Bool
loseRoudtrip PrintConfig
cfg
then Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"\\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> AstVarName s x -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s x
var
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor AstMethodLet s2 y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s2 y
l
else Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"tlambda $ \\"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> AstVarName s x -> ShowS
forall (s :: AstSpanType) (y :: TK).
AstSpan s =>
PrintConfig -> AstVarName s y -> ShowS
printAstVar PrintConfig
cfg AstVarName s x
var
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" -> "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> AstTensor AstMethodLet s2 y -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
0 AstTensor AstMethodLet s2 y
l
printAstBool :: PrintConfig -> Int -> AstBool ms -> ShowS
printAstBool :: forall (ms :: AstMethodOfSharing).
PrintConfig -> Int -> AstBool ms -> ShowS
printAstBool PrintConfig
cfg Int
d = \case
AstBoolConst Bool
b -> String -> ShowS
showString (String -> ShowS) -> String -> ShowS
forall a b. (a -> b) -> a -> b
$ if Bool
b then String
"true" else String
"false"
AstBoolNot AstBool ms
u -> (PrintConfig -> Int -> AstBool ms -> ShowS)
-> PrintConfig -> Int -> String -> [AstBool ms] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> AstBool ms -> ShowS
forall (ms :: AstMethodOfSharing).
PrintConfig -> Int -> AstBool ms -> ShowS
printAstBool PrintConfig
cfg Int
d String
"notB" [AstBool ms
u]
AstBoolAnd AstBool ms
u AstBool ms
v -> (PrintConfig -> Int -> AstBool ms -> ShowS)
-> PrintConfig
-> Int
-> AstBool ms
-> (Int, String)
-> AstBool ms
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> AstBool ms -> ShowS
forall (ms :: AstMethodOfSharing).
PrintConfig -> Int -> AstBool ms -> ShowS
printAstBool PrintConfig
cfg Int
d AstBool ms
u (Int
3, String
"&&*") AstBool ms
v
AstLeqK AstTensor ms PrimalSpan (TKScalar r)
u AstTensor ms PrimalSpan (TKScalar r)
v -> (PrintConfig
-> Int -> AstTensor ms PrimalSpan (TKScalar r) -> ShowS)
-> PrintConfig
-> Int
-> AstTensor ms PrimalSpan (TKScalar r)
-> (Int, String)
-> AstTensor ms PrimalSpan (TKScalar r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> AstTensor ms PrimalSpan (TKScalar r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms PrimalSpan (TKScalar r)
u (Int
4, String
"<=.") AstTensor ms PrimalSpan (TKScalar r)
v
AstLeqS AstTensor ms PrimalSpan (TKS sh r)
u AstTensor ms PrimalSpan (TKS sh r)
v -> (PrintConfig -> Int -> AstTensor ms PrimalSpan (TKS sh r) -> ShowS)
-> PrintConfig
-> Int
-> AstTensor ms PrimalSpan (TKS sh r)
-> (Int, String)
-> AstTensor ms PrimalSpan (TKS sh r)
-> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> AstTensor ms PrimalSpan (TKS sh r) -> ShowS
forall (s :: AstSpanType) (y :: TK) (ms :: AstMethodOfSharing).
AstSpan s =>
PrintConfig -> Int -> AstTensor ms s y -> ShowS
printAst PrintConfig
cfg Int
d AstTensor ms PrimalSpan (TKS sh r)
u (Int
4, String
"<=.") AstTensor ms PrimalSpan (TKS sh r)
v
printAstN1R :: (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeNum1 -> a -> ShowS
printAstN1R :: forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeNum1 -> a -> ShowS
printAstN1R PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d OpCodeNum1
opCode a
u = case OpCodeNum1
opCode of
OpCodeNum1
NegateOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"negate" [a
u]
OpCodeNum1
AbsOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"abs" [a
u]
OpCodeNum1
SignumOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"signum" [a
u]
printAstR1R :: (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode1 -> a -> ShowS
printAstR1R :: forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode1 -> a -> ShowS
printAstR1R PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d OpCode1
opCode a
u = case OpCode1
opCode of
OpCode1
RecipOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"recip" [a
u]
OpCode1
ExpOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"exp" [a
u]
OpCode1
LogOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"log" [a
u]
OpCode1
SqrtOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"sqrt" [a
u]
OpCode1
SinOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"sin" [a
u]
OpCode1
CosOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"cos" [a
u]
OpCode1
TanOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"tan" [a
u]
OpCode1
AsinOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"asin" [a
u]
OpCode1
AcosOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"acos" [a
u]
OpCode1
AtanOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"atan" [a
u]
OpCode1
SinhOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"sinh" [a
u]
OpCode1
CoshOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"cosh" [a
u]
OpCode1
TanhOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"tanh" [a
u]
OpCode1
AsinhOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"asinh" [a
u]
OpCode1
AcoshOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"acosh" [a
u]
OpCode1
AtanhOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"atanh" [a
u]
printAstR2R :: (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode2 -> a -> a -> ShowS
printAstR2R :: forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCode2 -> a -> a -> ShowS
printAstR2R PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d OpCode2
opCode a
u a
v = case OpCode2
opCode of
OpCode2
DivideOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d a
u (Int
7, String
"/") a
v
OpCode2
PowerOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d a
u (Int
8, String
"**") a
v
OpCode2
LogBaseOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"logBase" [a
u, a
v]
OpCode2
Atan2Op -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"atan2H" [a
u, a
v]
printAstI2R :: (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeIntegral2 -> a -> a -> ShowS
printAstI2R :: forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> OpCodeIntegral2 -> a -> a -> ShowS
printAstI2R PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d OpCodeIntegral2
opCode a
u a
v = case OpCodeIntegral2
opCode of
OpCodeIntegral2
QuotOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"quotH" [a
u, a
v]
OpCodeIntegral2
RemOp -> (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
"remH" [a
u, a
v]
printPrefixOp :: (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a]
-> ShowS
{-# INLINE printPrefixOp #-}
printPrefixOp :: forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> String -> [a] -> ShowS
printPrefixOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d String
funcname [a]
args =
let rs :: [ShowS]
rs = (a -> ShowS) -> [a] -> [ShowS]
forall a b. (a -> b) -> [a] -> [b]
map (\a
arg -> String -> ShowS
showString String
" " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
11 a
arg) [a]
args
in Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
funcname
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShowS -> ShowS -> ShowS) -> ShowS -> [ShowS] -> ShowS
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: Type -> Type) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) ShowS
forall a. a -> a
id [ShowS]
rs
printBinaryOp :: (PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a
-> ShowS
{-# INLINE printBinaryOp #-}
printBinaryOp :: forall a.
(PrintConfig -> Int -> a -> ShowS)
-> PrintConfig -> Int -> a -> (Int, String) -> a -> ShowS
printBinaryOp PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg Int
d a
left (Int
prec, String
opstr) a
right =
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
prec)
(ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) a
left
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString (String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
opstr String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" ")
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintConfig -> Int -> a -> ShowS
pr PrintConfig
cfg (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) a
right