summaryrefslogtreecommitdiff
path: root/src/Helium/Data
diff options
context:
space:
mode:
authorGreg Brown <greg.brown@cl.cam.ac.uk>2022-02-19 16:17:42 +0000
committerGreg Brown <greg.brown@cl.cam.ac.uk>2022-02-19 16:17:42 +0000
commite402e5fd5e44da78b8e266516294b57996fd5862 (patch)
tree248b276e935f1f0d7f93ba3099d806afa9303cb3 /src/Helium/Data
parent5250643e58e3eb4d277178f06c8984027ca3e01a (diff)
Add predicate for being a sliced type.
Diffstat (limited to 'src/Helium/Data')
-rw-r--r--src/Helium/Data/Pseudocode/Core.agda10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Helium/Data/Pseudocode/Core.agda b/src/Helium/Data/Pseudocode/Core.agda
index 6ae1d34..d683947 100644
--- a/src/Helium/Data/Pseudocode/Core.agda
+++ b/src/Helium/Data/Pseudocode/Core.agda
@@ -81,6 +81,16 @@ asType : Sliced → ℕ → Type
asType bits n = bits n
asType (array t) n = array t n
+sliced? : ∀ t → Dec (∃ λ t′ → ∃ λ n → asType t′ n ≡ t)
+sliced? bool = no (λ { (bits , ()) ; (array _ , ()) })
+sliced? int = no (λ { (bits , ()) ; (array _ , ()) })
+sliced? (fin n) = no (λ { (bits , ()) ; (array _ , ()) })
+sliced? real = no (λ { (bits , ()) ; (array _ , ()) })
+sliced? bit = no (λ { (bits , ()) ; (array _ , ()) })
+sliced? (bits n) = yes (bits , n , refl)
+sliced? (tuple n x) = no (λ { (bits , ()) ; (array _ , ()) })
+sliced? (array t n) = yes (array t , n , refl)
+
elemType : Sliced → Type
elemType bits = bit
elemType (array t) = t