{-# LANGUAGE GADTs #-}
module Data.Tensort.Utils.Types where
data TensortProps = TensortProps {TensortProps -> Int
bytesize :: Int, TensortProps -> SortAlg
subAlgorithm :: SortAlg}
type Bit = Int
type Byte = [Bit]
type Address = Int
type TopBit = Bit
type Record = (Address, TopBit)
type Register = [Record]
data Sortable
= SortBit [Bit]
| SortRec [Record]
deriving (Int -> Sortable -> ShowS
[Sortable] -> ShowS
Sortable -> String
(Int -> Sortable -> ShowS)
-> (Sortable -> String) -> ([Sortable] -> ShowS) -> Show Sortable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Sortable -> ShowS
showsPrec :: Int -> Sortable -> ShowS
$cshow :: Sortable -> String
show :: Sortable -> String
$cshowList :: [Sortable] -> ShowS
showList :: [Sortable] -> ShowS
Show, Sortable -> Sortable -> Bool
(Sortable -> Sortable -> Bool)
-> (Sortable -> Sortable -> Bool) -> Eq Sortable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Sortable -> Sortable -> Bool
== :: Sortable -> Sortable -> Bool
$c/= :: Sortable -> Sortable -> Bool
/= :: Sortable -> Sortable -> Bool
Eq, Eq Sortable
Eq Sortable =>
(Sortable -> Sortable -> Ordering)
-> (Sortable -> Sortable -> Bool)
-> (Sortable -> Sortable -> Bool)
-> (Sortable -> Sortable -> Bool)
-> (Sortable -> Sortable -> Bool)
-> (Sortable -> SortAlg)
-> (Sortable -> SortAlg)
-> Ord Sortable
Sortable -> Sortable -> Bool
Sortable -> Sortable -> Ordering
Sortable -> SortAlg
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Sortable -> Sortable -> Ordering
compare :: Sortable -> Sortable -> Ordering
$c< :: Sortable -> Sortable -> Bool
< :: Sortable -> Sortable -> Bool
$c<= :: Sortable -> Sortable -> Bool
<= :: Sortable -> Sortable -> Bool
$c> :: Sortable -> Sortable -> Bool
> :: Sortable -> Sortable -> Bool
$c>= :: Sortable -> Sortable -> Bool
>= :: Sortable -> Sortable -> Bool
$cmax :: Sortable -> SortAlg
max :: Sortable -> SortAlg
$cmin :: Sortable -> SortAlg
min :: Sortable -> SortAlg
Ord)
fromSortBit :: Sortable -> [Bit]
fromSortBit :: Sortable -> [Int]
fromSortBit (SortBit [Int]
bits) = [Int]
bits
fromSortBit (SortRec [Record]
_) = String -> [Int]
forall a. HasCallStack => String -> a
error String
"This is for sorting Bits - you gave me Records"
fromSortRec :: Sortable -> [Record]
fromSortRec :: Sortable -> [Record]
fromSortRec (SortRec [Record]
recs) = [Record]
recs
fromSortRec (SortBit [Int]
_) = String -> [Record]
forall a. HasCallStack => String -> a
error String
"This is for sorting Records - you gave me Bits"
type SortAlg = Sortable -> Sortable
type SupersortProps = (SortAlg, SortAlg, SortAlg, SupersortStrat)
type SupersortStrat = (Sortable, Sortable, Sortable) -> Sortable
data Memory
= ByteMem [Byte]
| TensorMem [Tensor]
deriving (Int -> Memory -> ShowS
[Memory] -> ShowS
Memory -> String
(Int -> Memory -> ShowS)
-> (Memory -> String) -> ([Memory] -> ShowS) -> Show Memory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Memory -> ShowS
showsPrec :: Int -> Memory -> ShowS
$cshow :: Memory -> String
show :: Memory -> String
$cshowList :: [Memory] -> ShowS
showList :: [Memory] -> ShowS
Show, Memory -> Memory -> Bool
(Memory -> Memory -> Bool)
-> (Memory -> Memory -> Bool) -> Eq Memory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Memory -> Memory -> Bool
== :: Memory -> Memory -> Bool
$c/= :: Memory -> Memory -> Bool
/= :: Memory -> Memory -> Bool
Eq, Eq Memory
Eq Memory =>
(Memory -> Memory -> Ordering)
-> (Memory -> Memory -> Bool)
-> (Memory -> Memory -> Bool)
-> (Memory -> Memory -> Bool)
-> (Memory -> Memory -> Bool)
-> (Memory -> Memory -> Memory)
-> (Memory -> Memory -> Memory)
-> Ord Memory
Memory -> Memory -> Bool
Memory -> Memory -> Ordering
Memory -> Memory -> Memory
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Memory -> Memory -> Ordering
compare :: Memory -> Memory -> Ordering
$c< :: Memory -> Memory -> Bool
< :: Memory -> Memory -> Bool
$c<= :: Memory -> Memory -> Bool
<= :: Memory -> Memory -> Bool
$c> :: Memory -> Memory -> Bool
> :: Memory -> Memory -> Bool
$c>= :: Memory -> Memory -> Bool
>= :: Memory -> Memory -> Bool
$cmax :: Memory -> Memory -> Memory
max :: Memory -> Memory -> Memory
$cmin :: Memory -> Memory -> Memory
min :: Memory -> Memory -> Memory
Ord)
type Tensor = (Register, Memory)
type TensorStack = Tensor
fromJust :: Maybe a -> a
fromJust :: forall a. Maybe a -> a
fromJust (Just a
x) = a
x
fromJust Maybe a
Nothing = String -> a
forall a. HasCallStack => String -> a
error String
"fromJust: Nothing"