@@ -92,6 +92,10 @@ pad64' n f x y = prim__lshrB64 (f (prim__shlB64 x pad) y) pad
9292 where
9393 pad = getPad {n=3} n
9494
95+-- TODO: This (and all the other functions along these lings) is public export
96+-- because it is used by public export things. Do they really need to be
97+-- public export, or is export good enough?
98+public export
9599shiftLeft' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
96100shiftLeft' {n=n} x c with (nextBytes n)
97101 | Z = pad8' n prim__shlB8 x c
@@ -103,6 +107,7 @@ public export
103107shiftLeft : Bits n -> Bits n -> Bits n
104108shiftLeft (MkBits x) (MkBits y) = MkBits (shiftLeft' x y)
105109
110+public export
106111shiftRightLogical' : machineTy n -> machineTy n -> machineTy n
107112shiftRightLogical' {n=n} x c with (n)
108113 | Z = prim__lshrB8 x c
@@ -115,6 +120,7 @@ shiftRightLogical : Bits n -> Bits n -> Bits n
115120shiftRightLogical {n} (MkBits x) (MkBits y)
116121 = MkBits {n} (shiftRightLogical' {n=nextBytes n} x y)
117122
123+public export
118124shiftRightArithmetic' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
119125shiftRightArithmetic' {n=n} x c with (nextBytes n)
120126 | Z = pad8' n prim__ashrB8 x c
@@ -126,6 +132,7 @@ public export
126132shiftRightArithmetic : Bits n -> Bits n -> Bits n
127133shiftRightArithmetic (MkBits x) (MkBits y) = MkBits (shiftRightArithmetic' x y)
128134
135+public export
129136and' : machineTy n -> machineTy n -> machineTy n
130137and' {n=n} x y with (n)
131138 | Z = prim__andB8 x y
@@ -137,6 +144,7 @@ public export
137144and : Bits n -> Bits n -> Bits n
138145and {n} (MkBits x) (MkBits y) = MkBits (and' {n=nextBytes n} x y)
139146
147+public export
140148or' : machineTy n -> machineTy n -> machineTy n
141149or' {n=n} x y with (n)
142150 | Z = prim__orB8 x y
@@ -148,6 +156,7 @@ public export
148156or : Bits n -> Bits n -> Bits n
149157or {n} (MkBits x) (MkBits y) = MkBits (or' {n=nextBytes n} x y)
150158
159+public export
151160xor' : machineTy n -> machineTy n -> machineTy n
152161xor' {n=n} x y with (n)
153162 | Z = prim__xorB8 x y
@@ -159,6 +168,7 @@ public export
159168xor : Bits n -> Bits n -> Bits n
160169xor {n} (MkBits x) (MkBits y) = MkBits {n} (xor' {n=nextBytes n} x y)
161170
171+public export
162172plus' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
163173plus' {n=n} x y with (nextBytes n)
164174 | Z = pad8 n prim__addB8 x y
@@ -170,6 +180,7 @@ public export
170180plus : Bits n -> Bits n -> Bits n
171181plus (MkBits x) (MkBits y) = MkBits (plus' x y)
172182
183+public export
173184minus' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
174185minus' {n=n} x y with (nextBytes n)
175186 | Z = pad8 n prim__subB8 x y
@@ -181,6 +192,7 @@ public export
181192minus : Bits n -> Bits n -> Bits n
182193minus (MkBits x) (MkBits y) = MkBits (minus' x y)
183194
195+public export
184196times' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
185197times' {n=n} x y with (nextBytes n)
186198 | Z = pad8 n prim__mulB8 x y
@@ -193,6 +205,7 @@ times : Bits n -> Bits n -> Bits n
193205times (MkBits x) (MkBits y) = MkBits (times' x y)
194206
195207partial
208+public export
196209sdiv' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
197210sdiv' {n=n} x y with (nextBytes n)
198211 | Z = prim__sdivB8 x y
@@ -205,6 +218,7 @@ sdiv : Bits n -> Bits n -> Bits n
205218sdiv (MkBits x) (MkBits y) = MkBits (sdiv' x y)
206219
207220partial
221+public export
208222udiv' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
209223udiv' {n=n} x y with (nextBytes n)
210224 | Z = prim__udivB8 x y
@@ -216,7 +230,7 @@ public export partial
216230udiv : Bits n -> Bits n -> Bits n
217231udiv (MkBits x) (MkBits y) = MkBits (udiv' x y)
218232
219−partial
233+public export partial
220234srem' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
221235srem' {n=n} x y with (nextBytes n)
222236 | Z = prim__sremB8 x y
@@ -228,7 +242,7 @@ public export partial
228242srem : Bits n -> Bits n -> Bits n
229243srem (MkBits x) (MkBits y) = MkBits (srem' x y)
230244
231−partial
245+public export partial
232246urem' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
233247urem' {n=n} x y with (nextBytes n)
234248 | Z = prim__uremB8 x y
@@ -276,9 +290,11 @@ gt {n=n} x y with (nextBytes n)
276290 | S (S Z) = prim__gtB32 x y
277291 | S (S (S _)) = prim__gtB64 x y
278292
293+public export
279294implementation Eq (Bits n) where
280295 (MkBits x) == (MkBits y) = boolOp eq x y
281296
297+public export
282298implementation Ord (Bits n) where
283299 (MkBits x) < (MkBits y) = boolOp lt x y
284300 (MkBits x) <= (MkBits y) = boolOp lte x y
@@ -291,6 +307,7 @@ implementation Ord (Bits n) where
291307 then EQ
292308 else GT
293309
310+public export
294311complement' : machineTy (nextBytes n) -> machineTy (nextBytes n)
295312complement' {n=n} x with (nextBytes n)
296313 | Z = let pad = getPad {n=0} n in
@@ -307,7 +324,7 @@ complement : Bits n -> Bits n
307324complement (MkBits x) = MkBits (complement' x)
308325
309326-- TODO: Prove
310−%assert_total -- can't verify coverage of with block
327+public export %assert_total -- can't verify coverage of with block
311328zext' : machineTy (nextBytes n) -> machineTy (nextBytes (n+m))
312329zext' {n=n} {m=m} x with (nextBytes n, nextBytes (n+m))
313330 | (Z, Z) = believe_me x
@@ -325,7 +342,7 @@ public export
325342zeroExtend : Bits n -> Bits (n+m)
326343zeroExtend (MkBits x) = MkBits (zext' x)
327344
328−%assert_total
345+public export %assert_total
329346intToBits' : Integer -> machineTy (nextBytes n)
330347intToBits' {n=n} x with (nextBytes n)
331348 | Z = let pad = getPad {n=0} n in
@@ -344,6 +361,7 @@ intToBits n = MkBits (intToBits' n)
344361implementation Cast Integer (Bits n) where
345362 cast = intToBits
346363
364+public export
347365bitsToInt' : machineTy (nextBytes n) -> Integer
348366bitsToInt' {n=n} x with (nextBytes n)
349367 | Z = prim__zextB8_BigInt x
@@ -356,6 +374,7 @@ bitsToInt : Bits n -> Integer
356374bitsToInt (MkBits x) = bitsToInt' x
357375
358376-- Zero out the high bits of a truncated bitstring
377+public export
359378zeroUnused : machineTy (nextBytes n) -> machineTy (nextBytes n)
360379zeroUnused {n} x = x `and'` complement' (intToBits' {n=n} 0)
361380
@@ -398,7 +417,7 @@ sext' {n=n} {m=m} x with (nextBytes n, nextBytes (n+m))
398417--signExtend {m=m} (MkBits x) = MkBits (zeroUnused (sext' x))
399418
400419-- TODO: Prove
401−%assert_total -- can't verify coverage of with block
420+public export %assert_total -- can't verify coverage of with block
402421trunc' : machineTy (nextBytes (m+n)) -> machineTy (nextBytes n)
403422trunc' {m=m} {n=n} x with (nextBytes n, nextBytes (m+n))
404423 | (Z, Z) = believe_me x