add set literals
This commit is contained in:
parent
b6ee28d704
commit
f72593ae85
@ -32,4 +32,22 @@ let peephole_expression : expression -> expression result = fun e ->
|
||||
in
|
||||
return @@ E_map []
|
||||
)
|
||||
| E_constant ("SET_LITERAL" , lst) -> (
|
||||
let%bind elt =
|
||||
trace_option (simple_error "map literal expects a single parameter") @@
|
||||
List.to_singleton lst
|
||||
in
|
||||
let%bind lst =
|
||||
trace (simple_error "map literal expects a list as parameter") @@
|
||||
get_e_list elt.expression
|
||||
in
|
||||
return @@ E_set lst
|
||||
)
|
||||
| E_constant ("SET_EMPTY" , lst) -> (
|
||||
let%bind () =
|
||||
trace_strong (simple_error "SET_EMPTY expects no parameter") @@
|
||||
Assert.assert_list_empty lst
|
||||
in
|
||||
return @@ E_set []
|
||||
)
|
||||
| e -> return e
|
||||
|
@ -147,6 +147,7 @@ module Simplify = struct
|
||||
|
||||
("Set.mem" , "SET_MEM") ;
|
||||
("Set.empty" , "SET_EMPTY") ;
|
||||
("Set.literal" , "SET_LITERAL") ;
|
||||
("Set.add" , "SET_ADD") ;
|
||||
("Set.remove" , "SET_REMOVE") ;
|
||||
("Set.fold" , "SET_FOLD") ;
|
||||
|
Loading…
Reference in New Issue
Block a user