never executed always true always false
1 module HelVM.HelMA.Automaton.Combiner.RAM (
2 genericLoad,
3 load,
4 flippedStoreChar,
5 storeChar,
6 genericStore,
7 store,
8 fromList,
9 RAM,
10 ) where
11
12 import HelVM.HelIO.Containers.LLIndexSafe
13 import HelVM.HelIO.Containers.LLInsertDef
14
15 import Data.Default
16 import Prelude hiding (divMod, drop, splitAt, swap)
17
18 genericLoad :: (Integral i , RAM ll element) => ll -> i -> element
19 genericLoad l = load l . fromIntegral
20
21 load :: (RAM ll element) => ll -> Address -> element
22 load l i = indexMaybe l i ?: def
23
24 flippedStoreChar :: (Num element , Integral address , RAM ll element) => address -> ll -> Char -> ll
25 flippedStoreChar a = flip (storeChar a)
26
27 storeChar :: (Num element , Integral address , RAM ll element) => address -> Char -> ll -> ll
28 storeChar a char = genericStore a $ ord char
29
30 genericStore :: (Integral value , Num element , Integral address , RAM ll element) => address -> value -> ll -> ll
31 genericStore a v = store a $ fromIntegral v
32
33 store :: (Integral a , RAM ll element) => a -> element -> ll -> ll
34 store = insertDef . fromIntegral
35
36 -- | Types
37 type RAM ll element = (Show ll , Default element , II ll element)
38
39 type II ll element = (InsertDef ll element , IndexSafe ll element)
40
41 type Address = Int