module Data.Express.Fixtures
(
module Data.Express
, b_, pp, qq, rr, pp'
, false
, true
, notE
, orE
, andE
, implies
, not'
, (-||-)
, (-&&-)
, (-==>-)
, (-==-)
, (-/=-)
, (-<=-)
, (-<-)
, compare'
, if'
, i_, xx, yy, zz, xx'
, ii, jj, kk, ii'
, ll, mm, nn
, zero, one, two, three, four, five, six
, seven, eight, nine, ten, eleven, twelve
, minusOne, minusTwo
, idE, negateE, absE, signumE
, idInt
, idBool
, idChar
, idInts
, idBools
, idString
, id', const', negate', abs', signum'
, plus, times, minus
, (-+-), (-*-)
, divE, modE, quotE, remE
, div', mod', quot', rem'
, ff, ffE
, gg, ggE
, hh, hhE
, oo, ooE
, question
, (-?-)
, (-$-)
, odd'
, even'
, c_, cs_
, cc, dd, ccs
, ae, bee, cee, dee, zed, zee
, space, lineBreak
, ord'
, ordE
, is_
, xxs
, yys
, zzs
, nil
, emptyString
, nilInt
, nilBool
, nilChar
, cons
, consInt
, consBool
, consChar
, (-:-)
, unit
, (-++-)
, head'
, tail'
, null'
, length'
, init'
, elem'
, sort'
, insert'
, bs_, pps, qqs
, and', or'
, sum', product'
, appendInt
, nothing
, nothingInt
, nothingBool
, just
, justInt
, justBool
, comma
, pair
, (-|-)
, triple
, quadruple
, quintuple
, sixtuple
, (-%-)
, compose
, mapE
, (-.-)
, map'
, enumFrom', (-..)
, enumFromTo', (-..-)
, enumFromThen', (-...)
, enumFromThenTo', (-...-)
)
where
import Data.Express
import Data.Maybe
import Data.Typeable (Typeable, typeOf)
import Data.Char
import Data.List
import Data.Ratio
int :: Int
int :: Int
int = Int
forall a. HasCallStack => a
undefined
bool :: Bool
bool :: Bool
bool = Bool
forall a. HasCallStack => a
undefined
char :: Char
char :: Char
char = Char
forall a. HasCallStack => a
undefined
string :: String
string :: String
string = String
forall a. HasCallStack => a
undefined
b_ :: Expr
b_ :: Expr
b_ = Bool -> Expr
forall a. Typeable a => a -> Expr
hole Bool
bool
pp :: Expr
pp :: Expr
pp = String -> Bool -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"p" Bool
bool
qq :: Expr
qq :: Expr
qq = String -> Bool -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"q" Bool
bool
rr :: Expr
rr :: Expr
rr = String -> Bool -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"r" Bool
bool
pp' :: Expr
pp' :: Expr
pp' = String -> Bool -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"p'" Bool
bool
false :: Expr
false :: Expr
false = Bool -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Bool
False
true :: Expr
true :: Expr
true = Bool -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Bool
True
notE :: Expr
notE :: Expr
notE = String -> (Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"not" Bool -> Bool
not
andE :: Expr
andE :: Expr
andE = String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"&&" Bool -> Bool -> Bool
(&&)
orE :: Expr
orE :: Expr
orE = String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"||" Bool -> Bool -> Bool
(||)
(-==>-) :: Expr -> Expr -> Expr
Expr
e1 -==>- :: Expr -> Expr -> Expr
-==>- Expr
e2 = Expr
implies Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2
infixr 0 -==>-
implies :: Expr
implies :: Expr
implies = String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==>" Bool -> Bool -> Bool
(==>)
where
Bool
False ==> :: Bool -> Bool -> Bool
==> Bool
_ = Bool
True
Bool
True ==> Bool
p = Bool
p
not' :: Expr -> Expr
not' :: Expr -> Expr
not' Expr
pp = Expr
notE Expr -> Expr -> Expr
:$ Expr
pp
(-&&-) :: Expr -> Expr -> Expr
Expr
pp -&&- :: Expr -> Expr -> Expr
-&&- Expr
qq = Expr
andE Expr -> Expr -> Expr
:$ Expr
pp Expr -> Expr -> Expr
:$ Expr
qq
infixr 3 -&&-
(-||-) :: Expr -> Expr -> Expr
Expr
pp -||- :: Expr -> Expr -> Expr
-||- Expr
qq = Expr
orE Expr -> Expr -> Expr
:$ Expr
pp Expr -> Expr -> Expr
:$ Expr
qq
infixr 2 -||-
i_ :: Expr
i_ :: Expr
i_ = Int -> Expr
forall a. Typeable a => a -> Expr
hole Int
int
xx :: Expr
xx :: Expr
xx = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"x" Int
int
yy :: Expr
yy :: Expr
yy = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"y" Int
int
zz :: Expr
zz :: Expr
zz = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"z" Int
int
xx' :: Expr
xx' :: Expr
xx' = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"x'" Int
int
ii :: Expr
ii :: Expr
ii = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"i" Int
int
jj :: Expr
jj :: Expr
jj = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"j" Int
int
kk :: Expr
kk :: Expr
kk = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"k" Int
int
ii' :: Expr
ii' :: Expr
ii' = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"i'" Int
int
ll :: Expr
ll :: Expr
ll = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"l" Int
int
mm :: Expr
mm :: Expr
mm = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"m" Int
int
nn :: Expr
nn :: Expr
nn = String -> Int -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"n" Int
int
zero :: Expr
zero :: Expr
zero = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
0 :: Int)
one :: Expr
one :: Expr
one = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
1 :: Int)
two :: Expr
two :: Expr
two = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
2 :: Int)
three :: Expr
three :: Expr
three = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
3 :: Int)
four :: Expr
four :: Expr
four = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
4 :: Int)
five :: Expr
five :: Expr
five = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
5 :: Int)
six :: Expr
six :: Expr
six = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
6 :: Int)
seven :: Expr
seven :: Expr
seven = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
7 :: Int)
eight :: Expr
eight :: Expr
eight = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
8 :: Int)
nine :: Expr
nine :: Expr
nine = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
9 :: Int)
ten :: Expr
ten :: Expr
ten = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
10 :: Int)
eleven :: Expr
eleven :: Expr
eleven = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
11 :: Int)
twelve :: Expr
twelve :: Expr
twelve = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Int
12 :: Int)
minusOne :: Expr
minusOne :: Expr
minusOne = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (-Int
1 :: Int)
minusTwo :: Expr
minusTwo :: Expr
minusTwo = Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (-Int
2 :: Int)
ff :: Expr -> Expr
ff :: Expr -> Expr
ff = (Expr
ffE Expr -> Expr -> Expr
:$)
ffE :: Expr
ffE :: Expr
ffE = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"f" (Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int)
gg :: Expr -> Expr
gg :: Expr -> Expr
gg = (Expr
ggE Expr -> Expr -> Expr
:$)
ggE :: Expr
ggE :: Expr
ggE = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"g" (Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int)
hh :: Expr -> Expr
hh :: Expr -> Expr
hh = (Expr
hhE Expr -> Expr -> Expr
:$)
hhE :: Expr
hhE :: Expr
hhE = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"h" (Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int)
(-?-) :: Expr -> Expr -> Expr
Expr
ex -?- :: Expr -> Expr -> Expr
-?- Expr
ey = Expr -> Maybe Expr -> Expr
forall a. a -> Maybe a -> a
fromMaybe Expr
forall a. a
err (Maybe Expr -> Expr) -> Maybe Expr -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Expr -> Maybe Expr
$$ Expr
ey) (Expr -> Maybe Expr) -> Expr -> Maybe Expr
forall a b. (a -> b) -> a -> b
$ Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"?" (Int -> Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int -> Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"?" (Bool -> Bool -> Bool
forall a. HasCallStack => a
undefined :: Bool -> Bool -> Bool)
, String -> (Char -> Char -> Char) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"?" (Char -> Char -> Char
forall a. HasCallStack => a
undefined :: Char -> Char -> Char)
, String -> ([Int] -> [Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"?" ([Int] -> [Int] -> [Int]
forall a. HasCallStack => a
undefined :: [Int] -> [Int] -> [Int])
, String -> (String -> String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"?" (String -> String -> String
forall a. HasCallStack => a
undefined :: String -> String -> String)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-?-): cannot apply `(?) :: * -> * -> *` to `"
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
ex String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"' and `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
ey String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"'. Unhandled types?"
question :: Expr
question :: Expr
question = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"?" (Int -> Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int -> Int)
oo :: Expr -> Expr -> Expr
Expr
ex oo :: Expr -> Expr -> Expr
`oo` Expr
ey = Expr -> Maybe Expr -> Expr
forall a. a -> Maybe a -> a
fromMaybe Expr
forall a. a
err (Maybe Expr -> Expr) -> Maybe Expr -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Expr -> Maybe Expr
$$ Expr
ey) (Expr -> Maybe Expr) -> Expr -> Maybe Expr
forall a b. (a -> b) -> a -> b
$ Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"`o`" (Int -> Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int -> Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"`o`" (Bool -> Bool -> Bool
forall a. HasCallStack => a
undefined :: Bool -> Bool -> Bool)
, String -> (Char -> Char -> Char) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"`o`" (Char -> Char -> Char
forall a. HasCallStack => a
undefined :: Char -> Char -> Char)
, String -> ([Int] -> [Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"`o`" ([Int] -> [Int] -> [Int]
forall a. HasCallStack => a
undefined :: [Int] -> [Int] -> [Int])
, String -> (String -> String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"`o`" (String -> String -> String
forall a. HasCallStack => a
undefined :: String -> String -> String)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"oo: cannot apply `o :: * -> * -> *` to `"
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
ex String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"' and `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
ey String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"'. Unhandled types?"
ooE :: Expr
ooE :: Expr
ooE = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"`o`" (Int -> Int -> Int
forall a. HasCallStack => a
undefined :: Int -> Int -> Int)
(-+-) :: Expr -> Expr -> Expr
Expr
e1 -+- :: Expr -> Expr -> Expr
-+- Expr
e2 = Expr
plus Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2
infixl 6 -+-
plus :: Expr
plus :: Expr
plus = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"+" (Int -> Int -> Int
forall a. Num a => a -> a -> a
(+) :: Int -> Int -> Int)
(-*-) :: Expr -> Expr -> Expr
Expr
e1 -*- :: Expr -> Expr -> Expr
-*- Expr
e2 = Expr
times Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2
infixl 7 -*-
times :: Expr
times :: Expr
times = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"*" (Int -> Int -> Int
forall a. Num a => a -> a -> a
(*) :: Int -> Int -> Int)
minus :: Expr
minus :: Expr
minus = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"-" ((-) :: Int -> Int -> Int)
div' :: Expr -> Expr -> Expr
Expr
ex div' :: Expr -> Expr -> Expr
`div'` Expr
ey = Expr
divE Expr -> Expr -> Expr
:$ Expr
ex Expr -> Expr -> Expr
:$ Expr
ey
divE :: Expr
divE :: Expr
divE = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"`div`" (Int -> Int -> Int
forall a. Integral a => a -> a -> a
div :: Int -> Int -> Int)
mod' :: Expr -> Expr -> Expr
Expr
ex mod' :: Expr -> Expr -> Expr
`mod'` Expr
ey = Expr
modE Expr -> Expr -> Expr
:$ Expr
ex Expr -> Expr -> Expr
:$ Expr
ey
modE :: Expr
modE :: Expr
modE = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"`mod`" (Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod :: Int -> Int -> Int)
quot' :: Expr -> Expr -> Expr
Expr
ex quot' :: Expr -> Expr -> Expr
`quot'` Expr
ey = Expr
quotE Expr -> Expr -> Expr
:$ Expr
ex Expr -> Expr -> Expr
:$ Expr
ey
quotE :: Expr
quotE :: Expr
quotE = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"`quot`" (Int -> Int -> Int
forall a. Integral a => a -> a -> a
quot :: Int -> Int -> Int)
rem' :: Expr -> Expr -> Expr
Expr
ex rem' :: Expr -> Expr -> Expr
`rem'` Expr
ey = Expr
remE Expr -> Expr -> Expr
:$ Expr
ex Expr -> Expr -> Expr
:$ Expr
ey
remE :: Expr
remE :: Expr
remE = String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"`rem`" (Int -> Int -> Int
forall a. Integral a => a -> a -> a
rem :: Int -> Int -> Int)
id' :: Expr -> Expr
id' :: Expr -> Expr
id' Expr
e = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
e)
[ Expr
idInt
, Expr
idBool
, Expr
idChar
, Expr
idInts
, Expr
idBools
, Expr
idString
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"id': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
e)
idE :: Expr
idE :: Expr
idE = Expr
idInt
idInt,idBool,idChar,idInts,idBools,idString :: Expr
idInt :: Expr
idInt = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"id" (Int -> Int
forall a. a -> a
id :: Id Int)
idBool :: Expr
idBool = String -> (Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"id" (Bool -> Bool
forall a. a -> a
id :: Id Bool)
idChar :: Expr
idChar = String -> (Char -> Char) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"id" (Char -> Char
forall a. a -> a
id :: Id Char)
idInts :: Expr
idInts = String -> ([Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"id" ([Int] -> [Int]
forall a. a -> a
id :: Id [Int])
idBools :: Expr
idBools = String -> Id [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"id" (Id [Bool]
forall a. a -> a
id :: Id [Bool])
idString :: Expr
idString = String -> (String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"id" (String -> String
forall a. a -> a
id :: Id String)
type Id a = a -> a
const' :: Expr -> Expr -> Expr
const' :: Expr -> Expr -> Expr
const' Expr
e1 Expr
e2 = (Expr -> Expr -> Expr
:$ Expr
e2) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
e1)
[ String -> (Int -> Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"const" (Int -> Int -> Int
forall a b. a -> b -> a
const :: Int -> Int -> Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"const" (Bool -> Bool -> Bool
forall a b. a -> b -> a
const :: Bool -> Bool -> Bool)
, String -> (Char -> Char -> Char) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"const" (Char -> Char -> Char
forall a b. a -> b -> a
const :: Char -> Char -> Char)
, String -> ([Int] -> [Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"const" ([Int] -> [Int] -> [Int]
forall a b. a -> b -> a
const :: [Int] -> [Int] -> [Int])
, String -> ([Bool] -> Id [Bool]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"const" ([Bool] -> Id [Bool]
forall a b. a -> b -> a
const :: [Bool] -> [Bool] -> [Bool])
, String -> (String -> String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"const" (String -> String -> String
forall a b. a -> b -> a
const :: String -> String -> String)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"const': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
e1)
negate' :: Expr -> Expr
negate' :: Expr -> Expr
negate' Expr
e = Expr
negateE Expr -> Expr -> Expr
:$ Expr
e
negateE :: Expr
negateE :: Expr
negateE = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"negate" (Int -> Int
forall a. Num a => a -> a
negate :: Int -> Int)
abs' :: Expr -> Expr
abs' :: Expr -> Expr
abs' Expr
e = Expr
absE Expr -> Expr -> Expr
:$ Expr
e
absE :: Expr
absE :: Expr
absE = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"abs" (Int -> Int
forall a. Num a => a -> a
abs :: Int -> Int)
signum' :: Expr -> Expr
signum' :: Expr -> Expr
signum' Expr
e = Expr
signumE Expr -> Expr -> Expr
:$ Expr
e
signumE :: Expr
signumE :: Expr
signumE = String -> (Int -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"signum" (Int -> Int
forall a. Num a => a -> a
signum :: Int -> Int)
odd' :: Expr -> Expr
odd' :: Expr -> Expr
odd' = (Expr
oddE Expr -> Expr -> Expr
:$) where oddE :: Expr
oddE = String -> (Int -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"odd" (Int -> Bool
forall a. Integral a => a -> Bool
odd :: Int -> Bool)
even' :: Expr -> Expr
even' :: Expr -> Expr
even' = (Expr
evenE Expr -> Expr -> Expr
:$) where evenE :: Expr
evenE = String -> (Int -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"even" (Int -> Bool
forall a. Integral a => a -> Bool
even :: Int -> Bool)
c_ :: Expr
c_ :: Expr
c_ = Char -> Expr
forall a. Typeable a => a -> Expr
hole Char
char
cs_ :: Expr
cs_ :: Expr
cs_ = String -> Expr
forall a. Typeable a => a -> Expr
hole [Char
char]
cc :: Expr
cc :: Expr
cc = String -> Char -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"c" Char
char
dd :: Expr
dd :: Expr
dd = String -> Char -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"d" Char
char
ccs :: Expr
ccs :: Expr
ccs = String -> String -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"cs" [Char
char]
ae :: Expr
ae :: Expr
ae = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'a'
bee :: Expr
bee :: Expr
bee = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'b'
cee :: Expr
cee :: Expr
cee = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'c'
dee :: Expr
dee :: Expr
dee = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'd'
zed :: Expr
zed :: Expr
zed = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'z'
zee :: Expr
zee :: Expr
zee = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'z'
space :: Expr
space :: Expr
space = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
' '
lineBreak :: Expr
lineBreak :: Expr
lineBreak = Char -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val Char
'\n'
ord' :: Expr -> Expr
ord' :: Expr -> Expr
ord' = (Expr
ordE Expr -> Expr -> Expr
:$)
ordE :: Expr
ordE :: Expr
ordE = String -> (Char -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"ord" Char -> Int
ord
is_ :: Expr
is_ :: Expr
is_ = [Int] -> Expr
forall a. Typeable a => a -> Expr
hole [Int
int]
xxs :: Expr
xxs :: Expr
xxs = String -> [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"xs" [Int
int]
yys :: Expr
yys :: Expr
yys = String -> [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"ys" [Int
int]
zzs :: Expr
zzs :: Expr
zzs = String -> [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"zs" [Int
int]
nil :: Expr
nil :: Expr
nil = Expr
nilInt
emptyString :: Expr
emptyString :: Expr
emptyString = String -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val String
""
nilInt, nilBool, nilChar :: Expr
nilInt :: Expr
nilInt = [Int] -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val ([] :: [Int])
nilBool :: Expr
nilBool = [Bool] -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val ([] :: [Bool])
nilChar :: Expr
nilChar = String -> String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"[]" ([] :: [Char])
cons :: Expr
cons :: Expr
cons = Expr
consInt
consInt, consBool, consChar :: Expr
consInt :: Expr
consInt = String -> Cons Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
":" ((:) :: Cons Int)
consBool :: Expr
consBool = String -> Cons Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
":" ((:) :: Cons Bool)
consChar :: Expr
consChar = String -> Cons Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
":" ((:) :: Cons Char)
type Cons a = a -> [a] -> [a]
unit :: Expr -> Expr
unit :: Expr -> Expr
unit Expr
e = Expr
e Expr -> Expr -> Expr
-:- Expr
nil'
where
nil' :: Expr
nil' | Expr -> TypeRep
typ Expr
e TypeRep -> TypeRep -> Bool
forall a. Eq a => a -> a -> Bool
== Expr -> TypeRep
typ Expr
i_ = Expr
nil
| Expr -> TypeRep
typ Expr
e TypeRep -> TypeRep -> Bool
forall a. Eq a => a -> a -> Bool
== Expr -> TypeRep
typ Expr
c_ = Expr
emptyString
| Expr -> TypeRep
typ Expr
e TypeRep -> TypeRep -> Bool
forall a. Eq a => a -> a -> Bool
== Expr -> TypeRep
typ Expr
b_ = Expr
nilBool
(-:-) :: Expr -> Expr -> Expr
Expr
e1 -:- :: Expr -> Expr -> Expr
-:- Expr
e2 = (Expr -> Expr -> Expr
:$ Expr
e2) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
e1)
[ Expr
consInt
, Expr
consBool
, Expr
consChar
, String -> Cons (Maybe Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
":" ((:) :: Cons (Maybe Int))
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-:-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
e1)
infixr 5 -:-
appendInt :: Expr
appendInt :: Expr
appendInt = String -> ([Int] -> [Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"++" ([Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
(++) :: [Int] -> [Int] -> [Int])
(-++-) :: Expr -> Expr -> Expr
Expr
e1 -++- :: Expr -> Expr -> Expr
-++- Expr
e2 = (Expr -> Expr -> Expr
:$ Expr
e2) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
e1)
[ String -> ([Int] -> [Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"++" ([Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
(++) :: [Int] -> [Int] -> [Int])
, String -> (String -> String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"++" (String -> String -> String
forall a. [a] -> [a] -> [a]
(++) :: String -> String -> String)
, String -> ([Bool] -> Id [Bool]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"++" ([Bool] -> Id [Bool]
forall a. [a] -> [a] -> [a]
(++) :: [Bool] -> [Bool] -> [Bool])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-++-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
e1)
infixr 5 -++-
head' :: Expr -> Expr
head' :: Expr -> Expr
head' Expr
exs = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
exs)
[ String -> ([Int] -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"head" ([Int] -> Int
forall a. [a] -> a
head :: [Int] -> Int)
, String -> (String -> Char) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"head" (String -> Char
forall a. [a] -> a
head :: [Char] -> Char)
, String -> ([Bool] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"head" ([Bool] -> Bool
forall a. [a] -> a
head :: [Bool] -> Bool)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"head': cannot apply `head :: [a] -> a` to `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
exs String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"'."
tail' :: Expr -> Expr
tail' :: Expr -> Expr
tail' Expr
exs = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
exs)
[ String -> ([Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"tail" ([Int] -> [Int]
forall a. [a] -> [a]
tail :: [Int] -> [Int])
, String -> (String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"tail" (String -> String
forall a. [a] -> [a]
tail :: [Char] -> [Char])
, String -> Id [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"tail" (Id [Bool]
forall a. [a] -> [a]
tail :: [Bool] -> [Bool])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"tail': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
exs)
null' :: Expr -> Expr
null' :: Expr -> Expr
null' Expr
exs = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
exs)
[ String -> ([Int] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"null" ([Int] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null :: [Int] -> Bool)
, String -> (String -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"null" (String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null :: [Char] -> Bool)
, String -> ([Bool] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"null" ([Bool] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null :: [Bool] -> Bool)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"null': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
exs)
length' :: Expr -> Expr
length' :: Expr -> Expr
length' Expr
exs = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
exs)
[ String -> ([Int] -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"length" ([Int] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length :: [Int] -> Int)
, String -> (String -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"length" (String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length :: [Char] -> Int)
, String -> ([Bool] -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"length" ([Bool] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length :: [Bool] -> Int)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"length': cannot apply `length :: [a] -> a` to `" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Expr -> String
forall a. Show a => a -> String
show Expr
exs String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"'."
init' :: Expr -> Expr
init' :: Expr -> Expr
init' Expr
exs = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
exs)
[ String -> ([Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"init" ([Int] -> [Int]
forall a. [a] -> [a]
init :: [Int] -> [Int])
, String -> (String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"init" (String -> String
forall a. [a] -> [a]
init :: [Char] -> [Char])
, String -> Id [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"init" (Id [Bool]
forall a. [a] -> [a]
init :: [Bool] -> [Bool])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"init': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
exs)
sort' :: Expr -> Expr
sort' :: Expr -> Expr
sort' Expr
exs = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
exs)
[ String -> ([Int] -> [Int]) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"sort" ([Int] -> [Int]
forall a. Ord a => [a] -> [a]
sort :: [Int] -> [Int])
, String -> (String -> String) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"sort" (String -> String
forall a. Ord a => [a] -> [a]
sort :: [Char] -> [Char])
, String -> Id [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"sort" (Id [Bool]
forall a. Ord a => [a] -> [a]
sort :: [Bool] -> [Bool])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"sort': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
exs)
insert' :: Expr -> Expr -> Expr
insert' :: Expr -> Expr -> Expr
insert' Expr
ex Expr
exs = (Expr -> Expr -> Expr
:$ Expr
exs) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Cons Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"insert" (Cons Int
forall a. Ord a => a -> [a] -> [a]
insert :: Int -> [Int] -> [Int])
, String -> Cons Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"insert" (Cons Bool
forall a. Ord a => a -> [a] -> [a]
insert :: Bool -> [Bool] -> [Bool])
, String -> Cons Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"insert" (Cons Char
forall a. Ord a => a -> [a] -> [a]
insert :: Char -> String -> String)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"insert': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
elem' :: Expr -> Expr -> Expr
elem' :: Expr -> Expr -> Expr
elem' Expr
ex Expr
exs = (Expr -> Expr -> Expr
:$ Expr
exs) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> (Int -> [Int] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"elem" (Int -> [Int] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem :: Int -> [Int] -> Bool)
, String -> (Bool -> [Bool] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"elem" (Bool -> [Bool] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem :: Bool -> [Bool] -> Bool)
, String -> (Char -> String -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"elem" (Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem :: Char -> String -> Bool)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"elem': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
(-$-) :: Expr -> Expr -> Expr
Expr
ef -$- :: Expr -> Expr -> Expr
-$- Expr
ex = (Expr -> Expr -> Expr
:$ Expr
ex) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ef)
[ String -> Apply Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"$" (Apply Int
forall a b. (a -> b) -> a -> b
($) :: Apply Int)
, String -> Apply Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"$" (Apply Bool
forall a b. (a -> b) -> a -> b
($) :: Apply Bool)
, String -> Apply Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"$" (Apply Char
forall a b. (a -> b) -> a -> b
($) :: Apply Char)
, String -> Apply [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"$" (Apply [Int]
forall a b. (a -> b) -> a -> b
($) :: Apply [Int])
, String -> Apply [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"$" (Apply [Bool]
forall a b. (a -> b) -> a -> b
($) :: Apply [Bool])
, String -> Apply String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"$" (Apply String
forall a b. (a -> b) -> a -> b
($) :: Apply [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-$-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ef)
infixl 6 -$-
type Apply a = (a -> a) -> a -> a
(-==-) :: Expr -> Expr -> Expr
Expr
ex -==- :: Expr -> Expr -> Expr
-==- Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Comparison () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Comparison ()
forall a. Eq a => a -> a -> Bool
(==) :: Comparison ())
, String -> Comparison Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Comparison Int
forall a. Eq a => a -> a -> Bool
(==) :: Comparison Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
(==) :: Comparison Bool)
, String -> Comparison Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Comparison Char
forall a. Eq a => a -> a -> Bool
(==) :: Comparison Char)
, String -> Comparison [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Comparison [Int]
forall a. Eq a => a -> a -> Bool
(==) :: Comparison [Int])
, String -> Comparison [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Comparison [Bool]
forall a. Eq a => a -> a -> Bool
(==) :: Comparison [Bool])
, String -> Comparison String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"==" (Comparison String
forall a. Eq a => a -> a -> Bool
(==) :: Comparison [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-==-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
infix 4 -==-
type Comparison a = a -> a -> Bool
(-/=-) :: Expr -> Expr -> Expr
Expr
ex -/=- :: Expr -> Expr -> Expr
-/=- Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Comparison () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Comparison ()
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison ())
, String -> Comparison Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Comparison Int
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison Bool)
, String -> Comparison Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Comparison Char
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison Char)
, String -> Comparison [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Comparison [Int]
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison [Int])
, String -> Comparison [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Comparison [Bool]
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison [Bool])
, String -> Comparison String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"/=" (Comparison String
forall a. Eq a => a -> a -> Bool
(/=) :: Comparison [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-/=-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
infix 4 -/=-
(-<=-) :: Expr -> Expr -> Expr
Expr
ex -<=- :: Expr -> Expr -> Expr
-<=- Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Comparison () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Comparison ()
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison ())
, String -> Comparison Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Comparison Int
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Bool -> Bool -> Bool
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison Bool)
, String -> Comparison Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Comparison Char
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison Char)
, String -> Comparison [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Comparison [Int]
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison [Int])
, String -> Comparison [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Comparison [Bool]
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison [Bool])
, String -> Comparison String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<=" (Comparison String
forall a. Ord a => a -> a -> Bool
(<=) :: Comparison [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-<=-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
infix 4 -<=-
(-<-) :: Expr -> Expr -> Expr
Expr
ex -<- :: Expr -> Expr -> Expr
-<- Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Comparison () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Comparison ()
forall a. Ord a => a -> a -> Bool
(<) :: Comparison ())
, String -> Comparison Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Comparison Int
forall a. Ord a => a -> a -> Bool
(<) :: Comparison Int)
, String -> (Bool -> Bool -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Bool -> Bool -> Bool
forall a. Ord a => a -> a -> Bool
(<) :: Comparison Bool)
, String -> Comparison Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Comparison Char
forall a. Ord a => a -> a -> Bool
(<) :: Comparison Char)
, String -> Comparison [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Comparison [Int]
forall a. Ord a => a -> a -> Bool
(<) :: Comparison [Int])
, String -> Comparison [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Comparison [Bool]
forall a. Ord a => a -> a -> Bool
(<) :: Comparison [Bool])
, String -> Comparison String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"<" (Comparison String
forall a. Ord a => a -> a -> Bool
(<) :: Comparison [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-<-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
infix 4 -<-
if' :: Expr -> Expr -> Expr -> Expr
if' :: Expr -> Expr -> Expr -> Expr
if' Expr
ep Expr
ex Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> ([Expr] -> [Expr]) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex) ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Expr) -> [Expr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (Expr -> Expr -> Expr
:$ Expr
ep)
[ String -> If () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If ()
forall a. Bool -> a -> a -> a
iff :: If ())
, String -> If Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If Int
forall a. Bool -> a -> a -> a
iff :: If Int)
, String -> If Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If Bool
forall a. Bool -> a -> a -> a
iff :: If Bool)
, String -> If Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If Char
forall a. Bool -> a -> a -> a
iff :: If Char)
, String -> If [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If [Int]
forall a. Bool -> a -> a -> a
iff :: If [Int])
, String -> If [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If [Bool]
forall a. Bool -> a -> a -> a
iff :: If [Bool])
, String -> If String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"if" (If String
forall a. Bool -> a -> a -> a
iff :: If [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"if': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
iff :: Bool -> a -> a -> a
iff :: Bool -> a -> a -> a
iff Bool
p a
x a
y = if Bool
p then a
x else a
y
type If a = Bool -> a -> a -> a
compare' :: Expr -> Expr -> Expr
compare' :: Expr -> Expr -> Expr
compare' Expr
ex Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Compare () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare ()
forall a. Ord a => a -> a -> Ordering
compare :: Compare ())
, String -> Compare Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare Int
forall a. Ord a => a -> a -> Ordering
compare :: Compare Int)
, String -> Compare Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare Bool
forall a. Ord a => a -> a -> Ordering
compare :: Compare Bool)
, String -> Compare Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare Char
forall a. Ord a => a -> a -> Ordering
compare :: Compare Char)
, String -> Compare [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare [Int]
forall a. Ord a => a -> a -> Ordering
compare :: Compare [Int])
, String -> Compare [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare [Bool]
forall a. Ord a => a -> a -> Ordering
compare :: Compare [Bool])
, String -> Compare String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"compare" (Compare String
forall a. Ord a => a -> a -> Ordering
compare :: Compare [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-<-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
type Compare a = a -> a -> Ordering
nothing :: Expr
nothing :: Expr
nothing = Expr
nothingInt
nothingInt :: Expr
nothingInt :: Expr
nothingInt = Maybe Int -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Maybe Int
forall a. Maybe a
Nothing :: Maybe Int)
nothingBool :: Expr
nothingBool :: Expr
nothingBool = Maybe Bool -> Expr
forall a. (Typeable a, Show a) => a -> Expr
val (Maybe Bool
forall a. Maybe a
Nothing :: Maybe Bool)
justInt :: Expr
justInt :: Expr
justInt = String -> (Int -> Maybe Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"Just" (Int -> Maybe Int
forall a. a -> Maybe a
Just :: Int -> Maybe Int)
justBool :: Expr
justBool :: Expr
justBool = String -> (Bool -> Maybe Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"Just" (Bool -> Maybe Bool
forall a. a -> Maybe a
Just :: Bool -> Maybe Bool)
just :: Expr -> Expr
just :: Expr -> Expr
just Expr
ex = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ Expr
justInt
, Expr
justBool
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"just: unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
(-|-) :: Expr -> Expr -> Expr
-|- :: Expr -> Expr -> Expr
(-|-) = Expr -> Expr -> Expr
pair
pair :: Expr -> Expr -> Expr
pair :: Expr -> Expr -> Expr
pair Expr
x Expr
y = Expr
comma Expr -> Expr -> Expr
:$ Expr
x Expr -> Expr -> Expr
:$ Expr
y
where
comma :: Expr
comma = case (TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> TypeRep -> String
forall a b. (a -> b) -> a -> b
$ Expr -> TypeRep
typ Expr
x, TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> TypeRep -> String
forall a b. (a -> b) -> a -> b
$ Expr -> TypeRep
typ Expr
y) of
(String
"Int", String
"Int") -> String -> Pair Int Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"," ((,) :: Pair Int Int)
(String
"Int", String
"Bool") -> String -> Pair Int Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"," ((,) :: Pair Int Bool)
(String
"Bool",String
"Int") -> String -> Pair Bool Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"," ((,) :: Pair Bool Int)
(String
"Bool",String
"Bool") -> String -> Pair Bool Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"," ((,) :: Pair Bool Bool)
(String
t,String
t') -> String -> Expr
forall a. HasCallStack => String -> a
error (String -> Expr) -> String -> Expr
forall a b. (a -> b) -> a -> b
$ String
"(-:-): unhandled types " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
t String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
t'
type Pair a b = a -> b -> (a,b)
comma :: Expr
comma :: Expr
comma = String -> Pair Int Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"," ((,) :: Pair Int Int)
triple :: Expr -> Expr -> Expr -> Expr
triple :: Expr -> Expr -> Expr -> Expr
triple Expr
e1 Expr
e2 Expr
e3 = Expr
ccE Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2 Expr -> Expr -> Expr
:$ Expr
e3
where
ccE :: Expr
ccE = String -> (Int -> Int -> Int -> (Int, Int, Int)) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",," ((,,) :: Int -> Int -> Int -> (Int,Int,Int))
quadruple :: Expr -> Expr -> Expr -> Expr -> Expr
quadruple :: Expr -> Expr -> Expr -> Expr -> Expr
quadruple Expr
e1 Expr
e2 Expr
e3 Expr
e4 = Expr
cccE Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2 Expr -> Expr -> Expr
:$ Expr
e3 Expr -> Expr -> Expr
:$ Expr
e4
where
cccE :: Expr
cccE = String
-> (Int -> Int -> Int -> Int -> (Int, Int, Int, Int)) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",,," ((,,,) :: Int -> Int -> Int -> Int -> (Int,Int,Int,Int))
quintuple :: Expr -> Expr -> Expr -> Expr -> Expr -> Expr
quintuple :: Expr -> Expr -> Expr -> Expr -> Expr -> Expr
quintuple Expr
e1 Expr
e2 Expr
e3 Expr
e4 Expr
e5 = Expr
ccccE Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2 Expr -> Expr -> Expr
:$ Expr
e3 Expr -> Expr -> Expr
:$ Expr
e4 Expr -> Expr -> Expr
:$ Expr
e5
where
ccccE :: Expr
ccccE = String
-> (Int -> Int -> Int -> Int -> Int -> (Int, Int, Int, Int, Int))
-> Expr
forall a. Typeable a => String -> a -> Expr
value String
",,,," ((,,,,) :: Int -> Int -> Int -> Int -> Int -> (Int,Int,Int,Int,Int))
sixtuple :: Expr -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr
sixtuple :: Expr -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr
sixtuple Expr
e1 Expr
e2 Expr
e3 Expr
e4 Expr
e5 Expr
e6 = Expr
cccccE Expr -> Expr -> Expr
:$ Expr
e1 Expr -> Expr -> Expr
:$ Expr
e2 Expr -> Expr -> Expr
:$ Expr
e3 Expr -> Expr -> Expr
:$ Expr
e4 Expr -> Expr -> Expr
:$ Expr
e5 Expr -> Expr -> Expr
:$ Expr
e6
where
cccccE :: Expr
cccccE = String
-> (Int
-> Int
-> Int
-> Int
-> Int
-> Int
-> (Int, Int, Int, Int, Int, Int))
-> Expr
forall a. Typeable a => String -> a -> Expr
value String
",,,,," ((,,,,,) :: Int -> Int -> Int -> Int -> Int -> Int -> (Int,Int,Int,Int,Int,Int))
bs_ :: Expr
bs_ :: Expr
bs_ = [Bool] -> Expr
forall a. Typeable a => a -> Expr
hole [Bool
bool]
pps :: Expr
pps :: Expr
pps = String -> [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"ps" [Bool
bool]
qqs :: Expr
qqs :: Expr
qqs = String -> [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
var String
"qs" [Bool
bool]
and' :: Expr -> Expr
and' :: Expr -> Expr
and' Expr
e = Expr
andE Expr -> Expr -> Expr
:$ Expr
e
where
andE :: Expr
andE = String -> ([Bool] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"and" ([Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and :: [Bool] -> Bool)
or' :: Expr -> Expr
or' :: Expr -> Expr
or' Expr
e = Expr
orE Expr -> Expr -> Expr
:$ Expr
e
where
orE :: Expr
orE = String -> ([Bool] -> Bool) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"or" ([Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
or :: [Bool] -> Bool)
sum' :: Expr -> Expr
sum' :: Expr -> Expr
sum' Expr
e = Expr
sumE Expr -> Expr -> Expr
:$ Expr
e
where
sumE :: Expr
sumE = String -> ([Int] -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"sum" ([Int] -> Int
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum :: [Int] -> Int)
product' :: Expr -> Expr
product' :: Expr -> Expr
product' Expr
e = Expr
productE Expr -> Expr -> Expr
:$ Expr
e
where
productE :: Expr
productE = String -> ([Int] -> Int) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"product" ([Int] -> Int
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product :: [Int] -> Int)
headOr :: a -> [a] -> a
headOr :: a -> [a] -> a
headOr a
x [] = a
x
headOr a
_ (a
x:[a]
_) = a
x
(-%-) :: Expr -> Expr -> Expr
Expr
en -%- :: Expr -> Expr -> Expr
-%- Expr
ed = String -> (Integer -> Integer -> Rational) -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"%" (Integer -> Integer -> Rational
forall a. Integral a => a -> a -> Ratio a
(%) :: Integer -> Integer -> Rational) Expr -> Expr -> Expr
:$ Expr
en Expr -> Expr -> Expr
:$ Expr
ed
compose :: Expr
compose :: Expr
compose = String -> Compose Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose Int)
(-.-) :: Expr -> Expr -> Expr
Expr
ex -.- :: Expr -> Expr -> Expr
-.- Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> Compose () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose ())
, String -> Compose Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose Int)
, String -> Compose Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose Bool)
, String -> Compose Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose Char)
, String -> Compose [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose [Int]
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose [Int])
, String -> Compose [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose [Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose [Bool])
, String -> Compose String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"." (Compose String
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) :: Compose [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-.-): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
type Compose a = (a -> a) -> (a -> a) -> (a -> a)
mapE :: Expr
mapE :: Expr
mapE = String -> Map Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map Int
forall a b. (a -> b) -> [a] -> [b]
map :: Map Int)
map' :: Expr -> Expr -> Expr
map' :: Expr -> Expr -> Expr
map' Expr
ef Expr
exs = (Expr -> Expr -> Expr
:$ Expr
exs) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ef)
[ String -> Map () -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map ()
forall a b. (a -> b) -> [a] -> [b]
map :: Map ())
, String -> Map Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map Int
forall a b. (a -> b) -> [a] -> [b]
map :: Map Int)
, String -> Map Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map Bool
forall a b. (a -> b) -> [a] -> [b]
map :: Map Bool)
, String -> Map Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map Char
forall a b. (a -> b) -> [a] -> [b]
map :: Map Char)
, String -> Map [Int] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map [Int]
forall a b. (a -> b) -> [a] -> [b]
map :: Map [Int])
, String -> Map [Bool] -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map [Bool]
forall a b. (a -> b) -> [a] -> [b]
map :: Map [Bool])
, String -> Map String -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"map" (Map String
forall a b. (a -> b) -> [a] -> [b]
map :: Map [Char])
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"map': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ef)
type Map a = (a -> a) -> [a] -> [a]
enumFrom' :: Expr -> Expr
enumFrom' :: Expr -> Expr
enumFrom' Expr
ex = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFrom Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFrom" (EnumFrom Int
forall a. Enum a => a -> [a]
enumFrom :: EnumFrom Int)
, String -> EnumFrom Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFrom" (EnumFrom Bool
forall a. Enum a => a -> [a]
enumFrom :: EnumFrom Bool)
, String -> EnumFrom Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFrom" (EnumFrom Char
forall a. Enum a => a -> [a]
enumFrom :: EnumFrom Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"enumFrom': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
type EnumFrom a = (a -> [a])
(-..) :: Expr -> Expr
-.. :: Expr -> Expr
(-..) Expr
ex = Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFrom Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
".." (EnumFrom Int
forall a. Enum a => a -> [a]
enumFrom :: EnumFrom Int)
, String -> EnumFrom Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
".." (EnumFrom Bool
forall a. Enum a => a -> [a]
enumFrom :: EnumFrom Bool)
, String -> EnumFrom Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
".." (EnumFrom Char
forall a. Enum a => a -> [a]
enumFrom :: EnumFrom Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"(-..): unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
enumFromTo' :: Expr -> Expr -> Expr
enumFromTo' :: Expr -> Expr -> Expr
enumFromTo' Expr
ex Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFromTo Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromTo" (EnumFromTo Int
forall a. Enum a => a -> a -> [a]
enumFromTo :: EnumFromTo Int)
, String -> EnumFromTo Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromTo" (EnumFromTo Bool
forall a. Enum a => a -> a -> [a]
enumFromTo :: EnumFromTo Bool)
, String -> EnumFromTo Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromTo" (EnumFromTo Char
forall a. Enum a => a -> a -> [a]
enumFromTo :: EnumFromTo Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"enumFromTo': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
type EnumFromTo a = (a -> a -> [a])
(-..-) :: Expr -> Expr -> Expr
Expr
ex -..- :: Expr -> Expr -> Expr
-..- Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFromTo Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
".." (EnumFromTo Int
forall a. Enum a => a -> a -> [a]
enumFromTo :: EnumFromTo Int)
, String -> EnumFromTo Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
".." (EnumFromTo Bool
forall a. Enum a => a -> a -> [a]
enumFromTo :: EnumFromTo Bool)
, String -> EnumFromTo Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
".." (EnumFromTo Char
forall a. Enum a => a -> a -> [a]
enumFromTo :: EnumFromTo Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"-..-: unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
enumFromThen' :: Expr -> Expr -> Expr
enumFromThen' :: Expr -> Expr -> Expr
enumFromThen' Expr
ex Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFromTo Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromThen" (EnumFromTo Int
forall a. Enum a => a -> a -> [a]
enumFromThen :: EnumFromThen Int)
, String -> EnumFromTo Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromThen" (EnumFromTo Bool
forall a. Enum a => a -> a -> [a]
enumFromThen :: EnumFromThen Bool)
, String -> EnumFromTo Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromThen" (EnumFromTo Char
forall a. Enum a => a -> a -> [a]
enumFromThen :: EnumFromThen Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"enumFromThen': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
type EnumFromThen a = (a -> a -> [a])
(-...) :: Expr -> Expr -> Expr
Expr
ex -... :: Expr -> Expr -> Expr
-... Expr
ey = (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFromTo Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",.." (EnumFromTo Int
forall a. Enum a => a -> a -> [a]
enumFromThen :: EnumFromThen Int)
, String -> EnumFromTo Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",.." (EnumFromTo Bool
forall a. Enum a => a -> a -> [a]
enumFromThen :: EnumFromThen Bool)
, String -> EnumFromTo Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",.." (EnumFromTo Char
forall a. Enum a => a -> a -> [a]
enumFromThen :: EnumFromThen Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"-..-: unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
enumFromThenTo' :: Expr -> Expr -> Expr -> Expr
enumFromThenTo' :: Expr -> Expr -> Expr -> Expr
enumFromThenTo' Expr
ex Expr
ey Expr
ez = (Expr -> Expr -> Expr
:$ Expr
ez) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFromThenTo Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromThenTo" (EnumFromThenTo Int
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo :: EnumFromThenTo Int)
, String -> EnumFromThenTo Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromThenTo" (EnumFromThenTo Bool
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo :: EnumFromThenTo Bool)
, String -> EnumFromThenTo Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
"enumFromThenTo" (EnumFromThenTo Char
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo :: EnumFromThenTo Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"enumFromThenTo': unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)
type EnumFromThenTo a = (a -> a -> a -> [a])
(-...-) :: Expr -> Expr -> Expr -> Expr
(Expr
ex -...- :: Expr -> Expr -> Expr -> Expr
-...- Expr
ey) Expr
ez = (Expr -> Expr -> Expr
:$ Expr
ez) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Expr -> Expr -> Expr
:$ Expr
ey) (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> [Expr] -> Expr
forall a. a -> [a] -> a
headOr Expr
forall a. a
err ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (Expr -> Maybe Expr) -> [Expr] -> [Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Expr -> Expr -> Maybe Expr
$$ Expr
ex)
[ String -> EnumFromThenTo Int -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",.." (EnumFromThenTo Int
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo :: EnumFromThenTo Int)
, String -> EnumFromThenTo Bool -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",.." (EnumFromThenTo Bool
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo :: EnumFromThenTo Bool)
, String -> EnumFromThenTo Char -> Expr
forall a. Typeable a => String -> a -> Expr
value String
",.." (EnumFromThenTo Char
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo :: EnumFromThenTo Char)
]
where
err :: a
err = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"-..-: unhandled type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (Expr -> TypeRep
typ Expr
ex)