Allow terms to have both extractors and constructors

Fixes #4
This commit is contained in:
Nick Fitzgerald
2021-10-07 16:38:47 -07:00
committed by Chris Fallin
parent fddff6ee2d
commit 7f8cb75e54
4 changed files with 420 additions and 116 deletions

View File

@@ -0,0 +1,17 @@
(type i32 (primitive i32))
(type B (enum (B (x i32) (y i32))))
;; `isub` has a constructor and extractor.
(decl isub (i32 i32) B)
(rule (isub x y)
(B.B x y))
(extractor (isub x y)
(B.B x y))
;; `value_array_2` has both an external extractor and an external constructor.
(type Value (primitive Value))
(type ValueArray2 extern (enum))
(decl value_array_2 (Value Value) ValueArray2)
(extern extractor infallible value_array_2 unpack_value_array_2)
(extern constructor value_array_2 pack_value_array_2)