text
stringlengths
12
786k
let ts_format6 = ts ( Ident . create ~ loc : Location . none " format6 " ) [ fresh_tv ~ loc : Location . none " a " ; fresh_tv ~ loc : Location . none " b " ; fresh_tv ~ loc : Location . none " c " ; fresh_tv ~ loc : Location . none " d " ; fresh_tv ~ loc : Location . none " e " ; fresh_tv ~ loc : Location . none " f " ; ]
let ts_lazy = ts ( Ident . create ~ loc : Location . none " lazy " ) [ fresh_tv ~ loc : Location . none " a " ]
let ts_tuple = let ts_tuples = Hashtbl . create 0 in Hashtbl . add ts_tuples 0 ts_unit ; fun n -> try Hashtbl . find ts_tuples n with Not_found -> let ts_id = Ident . create ~ loc : Location . none ( " tuple " ^ string_of_int n ) in let ts_args = List . init n ( fun x -> fresh_tv ~ loc : Location . none ( " a " ^ string_of_int x ) ) in let ts = ts ts_id ts_args in Hashtbl . add ts_tuples n ts ; ts
let ts_arrow = let ta = fresh_tv ~ loc : Location . none " a " in let tb = fresh_tv ~ loc : Location . none " b " in let id = Ident . create ~ loc : Location . none " " -> in ts id [ ta ; tb ]
let is_ts_tuple ts = let ts_tuple = ts_tuple ( ts_arity ts ) in Ident . equal ts_tuple . ts_ident ts . ts_ident
let is_ts_arrow ts = Ident . equal ts_arrow . ts_ident ts . ts_ident
let ty_unit = ty_app ts_unit [ ]
let ty_integer = ty_app ts_integer [ ]
let ty_int = ty_app ts_int [ ]
let ty_bool = ty_app ts_bool [ ]
let ty_float = ty_app ts_float [ ]
let ty_char = ty_app ts_char [ ]
let ty_string = ty_app ts_string [ ]
let ty_option ty = ty_app ts_option [ ty ]
let ty_list ty = ty_app ts_list [ ty ]
let ty_tuple = function | [ ] -> ty_unit | [ ty ] -> ty | tyl -> ty_app ( ts_tuple ( List . length tyl ) ) tyl
type exn_type = | Exn_tuple of ty list | Exn_record of ( Ident . t * ty ) list
type xsymbol = { xs_ident : Ident . t ; xs_type : exn_type } [ @@ deriving show ]
let xsymbol id ty = { xs_ident = id ; xs_type = ty }
let xs_equal x y = Ident . equal x . xs_ident y . xs_ident
module Xs = struct type t = xsymbol let equal = xs_equal let compare x y = Ident . compare x . xs_ident y . xs_ident end
module Mxs = Map . Make ( Xs )
let xs_subst_ts old_ts new_ts { xs_ident ; xs_type } = let subst = function | Exn_tuple tyl -> Exn_tuple ( List . map ( ty_subst_ts old_ts new_ts ) tyl ) | Exn_record l -> Exn_record ( List . map ( fun ( id , ty ) -> ( id , ty_subst_ts old_ts new_ts ty ) ) l ) in xsymbol xs_ident ( subst xs_type )
let xs_subst_ty old_ts new_ts new_ty xs = let subst = function | Exn_tuple tyl -> let subst ty = ty_subst_ty old_ts new_ts new_ty ty in Exn_tuple ( List . map subst tyl ) | Exn_record l -> let subst ( id , ty ) = ( id , ty_subst_ty old_ts new_ts new_ty ty ) in Exn_record ( List . map subst l ) in { xs with xs_type = subst xs . xs_type }
let print_tv fmt tv = pp fmt ( if tv . tv_name . id_str = " _ " then " % a " else " ' % a " ) Ident . pp tv . tv_name
let print_ts_name fmt ts = pp fmt " [ @% a ] " @ Ident . pp ( ts_ident ts )
let rec print_ty fmt { ty_node } = print_ty_node fmt ty_node | Tyvar v -> pp fmt " % a " print_tv v | Tyapp ( ts , [ ] ) -> print_ts_name fmt ts | Tyapp ( ts , tys ) when is_ts_arrow ts -> print_arrow_ty fmt tys | Tyapp ( ts , tyl ) when is_ts_tuple ts -> pp fmt " % a " ( list ~ sep : star print_ty ) tyl | Tyapp ( ts , [ ty ] ) -> pp fmt " % a % a " print_ty ty print_ts_name ts | Tyapp ( ts , tyl ) -> pp fmt " ( % a ) % a " ( list ~ sep : comma print_ty ) tyl print_ts_name ts
let print_ts fmt ts = pp fmt " [ @% a % a % a ] " @ ( list ~ sep : comma ~ first : lparens ~ last : rparens print_tv ) ts . ts_args Ident . pp ( ts_ident ts ) ( fun fmt alias -> match alias with None -> ( ) | Some ty -> pp fmt " [ =% a ] " print_ty ty ) ts . ts_alias
let print_exn_type f = function | Exn_tuple tyl -> list ~ sep : star print_ty f tyl | Exn_record args -> let print_arg f ( id , ty ) = pp f " % a :% a " Ident . pp id print_ty ty in list ~ sep : semi ~ first : rbrace ~ last : lbrace print_arg f args
let print_xs f x = pp f " % a " Ident . pp x . xs_ident
module User_input = struct type t = | Ctrl_c | Escape | Backspace | Return | Char of char [ @@ deriving sexp_of ] end
module Configure_terminal = struct type t = { attr_in : Unix . Terminal_io . t ; attr_out : Unix . Terminal_io . t ; } let setattr_out fd ~ attr_out = Unix . Terminal_io . tcsetattr attr_out ~ mode : Unix . Terminal_io . TCSAFLUSH fd let setattr_in fd ~ attr_in = Unix . Terminal_io . tcsetattr attr_in ~ mode : Unix . Terminal_io . TCSADRAIN fd let get_current_settings ~ input ~ output ( ) = let % bind attr_in = Unix . Terminal_io . tcgetattr input in let % bind attr_out = Unix . Terminal_io . tcgetattr output in return { attr_in = attr_in ; attr_out = attr_out ; } let set ~ input ~ output t = let % bind ( ) = setattr_in input ~ attr_in : t . attr_in in let % bind ( ) = setattr_out output ~ attr_out : t . attr_out in return ( ) let map_termio ( attrs : Core . Unix . Terminal_io . t ) = { attrs with Core . Unix . Terminal_io . c_ignbrk = false ; c_brkint = false ; c_parmrk = false ; c_istrip = false ; c_inlcr = false ; c_igncr = false ; c_icrnl = false ; c_ixon = false ; c_opost = false ; c_echo = false ; c_echonl = false ; c_icanon = false ; c_isig = false ; c_csize = 8 ; c_parenb = false ; c_vmin = 1 ; c_vtime = 0 ; } ; ; let to_drawing t = { attr_in = map_termio t . attr_in ; attr_out = map_termio t . attr_out } ; ; end
let esc rest = " \ x1b [ " ^ rest ; ;
module Direction = struct type t = | Up | Down | Left | Right [ @@ deriving enumerate ] let escape = function | Up -> esc " A " | Down -> esc " B " | Right -> esc " C " | Left -> esc " D " end
module Action = struct type t = | Clear_screen | Move_cursor_to_home | Next_line | Move of Direction . t | Switch_to_alternate_buffer | Switch_from_alternate_buffer | Erase_to_end_of_line let _compilation_fix_for_unused_constructor = Move Left let to_string = function | Clear_screen -> esc " 2J " | Erase_to_end_of_line -> esc " K " | Move_cursor_to_home -> esc " H " | Next_line -> " \ r \ n " | Move dir -> Direction . escape dir | Switch_to_alternate_buffer -> esc " ? 1049h " | Switch_from_alternate_buffer -> esc " ? 1049l " end
let do_action writer action = Writer . write writer ( Action . to_string action ) ; Writer . flushed writer ; ;
type t = { dimensions : Screen_dimensions . t ; writer : Writer . t }
let screen_dimensions { dimensions ; _ } = dimensions
let stop_rendering t = do_action t Switch_from_alternate_buffer ; ;
let with_rendering f = let % bind tty_reader = Reader . open_file ~ buf_len : 1 " / dev / tty " in let % bind tty_writer = Writer . open_file " / dev / tty " in let input = Reader . fd tty_reader in let output = Writer . fd tty_writer in let % bind original = Configure_terminal . get_current_settings ~ input ~ output ( ) in let restore ( ) = Configure_terminal . set original ~ input ~ output in let % bind dimensions = let % map output = Process . run_exn ( ) ~ prog " : stty " ~ args [ : " size " ; " - F " ; " / dev / tty " ] in match output |> String . strip |> String . split ~ on ' : ' with | [ height ; width ] -> { Screen_dimensions . height = Int . of_string height ; width = Int . of_string width } | _ -> raise_s [ % message " Could not determine terminal size " ] in Monitor . protect ~ finally : restore ( fun ( ) -> let t = { dimensions ; writer = tty_writer } in let % bind ( ) = Configure_terminal . to_drawing original |> Configure_terminal . set ~ input ~ output in let % bind ( ) = do_action tty_writer Switch_to_alternate_buffer in let % bind ( ) = do_action tty_writer Clear_screen in let user_input = Pipe . create_reader ~ close_on_exception : true ( fun w -> let repeat x = let % bind ( ) = Pipe . write w x in return ( ` Repeat ( ) ) in let b = Bytes . create 1 in Deferred . repeat_until_finished ( ) ( fun ( ) -> match % bind Reader . really_read ~ len : 1 tty_reader b with | ` Eof _ -> return ( ` Finished ( ) ) | ` Ok -> match Char . to_int ( Bytes . get b 0 ) with | 3 -> let % bind ( ) = Pipe . write w User_input . Ctrl_c in return ( ` Finished ( ) ) | 0O177 -> repeat Backspace | 0O015 -> repeat Return | 0O33 -> repeat Escape | _ -> repeat ( Char ( Bytes . get b 0 ) ) ) ) in let % bind to_return = f ( user_input , t ) in let % bind ( ) = restore ( ) in let % bind ( ) = stop_rendering t . writer in return to_return ) ; ;
module Widget = struct type t = | Text of string | Group_horizontally of t list | Stack_vertically of t list let text text = Text text let horizontal_group ts = Group_horizontally ts let vertical_group ts = Stack_vertically ts let render elts writer = let rec process = function | Text x -> Writer . writef writer " % s " x | Group_horizontally xs -> List . iter xs ~ f : process | Stack_vertically xs -> xs |> List . map ~ f ( : fun x -> ( fun ( ) -> process x ) ) |> List . intersperse ~ sep ( : fun ( ) -> Writer . writef writer " { !% Action } { % Action } " Erase_to_end_of_line Next_line ) |> List . iter ~ f ( : fun f -> f ( ) ) in Writer . writef writer " { !% Action } " Move_cursor_to_home ; process elts ; Writer . writef writer " { !% Action } " Erase_to_end_of_line ; Writer . flushed writer end
let render t w = Widget . render w t . writer ; ;
type kind = Tap | Tun -> int -> int -> Unix . file_descr * string = " tun_opendev_byte " " tun_opendev "
let open_ kind ( ? pi = false ) false ? persist ( ? user = - 1 ) 1 ( ? group = - 1 ) 1 ( ? devname ) " " = ( ) = let persist_int = match persist with | None -> - 1 | Some false -> 0 | Some true -> 1 in opentun_stub devname kind pi persist_int user group
let opentun = open_ Tun
let opentap = open_ Tap
let closetun devname = ignore ( opentun ~ devname ~ persist : false ( ) )
let closetap devname = ignore ( opentap ~ devname ~ persist : false ( ) )
let set_ipv4 ( ? netmask = Ipaddr . V4 . Prefix . global ) global devname v4addr = let open Ipaddr . V4 in set_ipv4 devname ( to_octets v4addr ) v4addr ( to_octets ( Prefix . netmask netmask ) netmask ) netmask
let get_macaddr iface = Macaddr . of_octets_exn ( get_macaddr iface ) iface
module Opt = struct let ( ) >|= x f = match x with Some v -> Some ( f v ) v | None -> None let run = function | Some x -> x | None -> raise Not_found end
module Struct_ifaddrs = struct type t = { name : string ; sa_family : int ; addr : string option ; mask : string option ; brd : string option ; } type ptr_t external getifaddrs_stub : unit -> ptr_t option = " getifaddrs_stub " external freeifaddrs_stub : ptr_t -> unit = " freeifaddrs_stub " external iface_get : ptr_t -> t = " iface_get " external iface_next : ptr_t -> ptr_t option = " iface_next " let to_t ' t = let open Ipaddr in let open Opt in match t . sa_family with | 0 -> let address = run ( t . addr >|= fun v -> V4 . of_octets_exn v ) v and netmask = run ( t . mask >|= fun v -> V4 . of_octets_exn v ) v in Some ( t . name , ` V4 ( V4 . Prefix . of_netmask_exn ~ netmask ~ address ) address ) address | 1 -> let address = run ( t . addr >|= fun v -> V6 . of_octets_exn v ) v and netmask = run ( t . mask >|= fun v -> V6 . of_octets_exn v ) v in Some ( t . name , ` V6 ( V6 . Prefix . of_netmask_exn ~ netmask ~ address ) address ) address | _ -> None end
let getifaddrs ( ) = let open Struct_ifaddrs in match getifaddrs_stub ( ) with | None -> [ ] | Some start -> let rec loop acc ptr = let acc = match to_t ' ( iface_get ptr ) ptr with | None -> acc | Some t ' -> t ' :: acc in match iface_next ptr with | None -> freeifaddrs_stub start ; acc | Some p -> loop acc p in loop [ ] start
let filter_map f l = List . fold_left ( fun a v -> match f v with Some v ' -> v ' :: a | None -> a ) a [ ] l
let getifaddrs_v4 ( ) = filter_map ( function ( ifn , ` V4 a ) a -> Some ( ifn , a ) a | _ -> None ) None @@ getifaddrs ( )
let getifaddrs_v6 ( ) = filter_map ( function ( ifn , ` V6 a ) a -> Some ( ifn , a ) | _ -> None ) None @@ getifaddrs ( )
let addrs_of_ifname ifname = filter_map ( fun ( ifn , a ) a -> if ifn = ifname then Some a else None ) None @@ getifaddrs ( )
let v4_of_ifname ifname = filter_map ( fun ( ifn , a ) a -> if ifn = ifname then Some a else None ) None @@ getifaddrs_v4 ( )
let v6_of_ifname ifname = filter_map ( fun ( ifn , a ) a -> if ifn = ifname then Some a else None ) None @@ getifaddrs_v6 ( )
let first ( a , _ ) = a
module type MAGMA_F = functor ( First : MAGMA ) ( Second : MAGMA ) -> MAGMA with type t = First . t * Second . t
module type SEMIGROUP_F = functor ( First : SEMIGROUP ) ( Second : SEMIGROUP ) -> SEMIGROUP with type t = First . t * Second . t
module type MONOID_F = functor ( First : MONOID ) ( Second : MONOID ) -> MONOID with type t = First . t * Second . t
module type FUNCTOR_F = functor ( T : TYPE ) -> FUNCTOR with type ' a t = T . t * ' a
module type APPLY_F = functor ( S : SEMIGROUP ) -> APPLY with type ' a t = S . t * ' a
module type APPLICATIVE_F = functor ( M : MONOID ) -> APPLICATIVE with type ' a t = M . t * ' a
module type MONAD_F = functor ( M : MONOID ) -> MONAD with type ' a t = M . t * ' a
module type FOLDABLE_F = functor ( T : TYPE ) -> FOLDABLE with type ' a t = T . t * ' a
module type EQ_F = functor ( First : EQ ) ( Second : EQ ) -> EQ with type t = First . t * Second . t
module type SHOW_F = functor ( First : SHOW ) ( Second : SHOW ) -> SHOW with type t = First . t * Second . t
module type TRAVERSABLE_F = functor ( T : TYPE ) ( A : APPLICATIVE ) -> TRAVERSABLE with type ' a t = T . t * ' a and type ' a applicative_t = ' a A . t
module Magma : MAGMA_F = functor ( First : MAGMA ) ( Second : MAGMA ) -> struct type t = First . t * Second . t let append ( a , b ) ( a ' , b ' ) = First . append a a ' , Second . append b b ' end
module Semigroup : SEMIGROUP_F = functor ( First : SEMIGROUP ) ( Second : SEMIGROUP ) -> struct include Magma ( First ) ( Second ) end
module Monoid : MONOID_F = functor ( First : MONOID ) ( Second : MONOID ) -> struct include Semigroup ( First ) ( Second ) let empty = First . empty , Second . empty end
module Functor : FUNCTOR_F = functor ( T : TYPE ) -> struct type ' a t = T . t * ' a let map f ( a , b ) = a , f b end
module Apply : APPLY_F = functor ( S : SEMIGROUP ) -> struct include Functor ( S ) let apply ( a , f ) ( a ' , x ) = S . append a a ' , f x end
module Applicative : APPLICATIVE_F = functor ( M : MONOID ) -> struct include Apply ( M ) let pure a = M . empty , a end
module Monad : MONAD_F = functor ( M : MONOID ) -> struct include Applicative ( M ) let flat_map ( a , b ) f = match f b with | a ' , c -> M . append a a ' , c end
module Foldable : FOLDABLE_F = functor ( T : TYPE ) -> struct type ' a t = T . t * ' a let fold_left f init ( _ , x ) = f init x and fold_right f init ( _ , x ) = f x init module Fold = struct let fold_map f ( _ , x ) = f x end module Fold_Map ( M : MONOID ) = struct include Fold end module Fold_Map_Plus ( P : PLUS ) = struct include Fold end module Fold_Map_Any ( M : MONOID_ANY ) = struct include Fold end end
module Traversable : TRAVERSABLE_F = functor ( T : TYPE ) ( A : APPLICATIVE ) -> struct type ' a t = T . t * ' a and ' a applicative_t = ' a A . t include ( Functor ( T ) : FUNCTOR with type ' a t := ' a t ) include ( Foldable ( T ) : FOLDABLE with type ' a t := ' a t ) let traverse f ( x , y ) = A . map ( fun z -> x , z ) ( f y ) and sequence ( x , y ) = A . map ( fun z -> x , z ) y end
module Eq : EQ_F = functor ( First : EQ ) ( Second : EQ ) -> struct type t = First . t * Second . t let eq ( a , b ) ( a ' , b ' ) = First . eq a a ' && Second . eq b b ' end
module Semigroupoid : SEMIGROUPOID with type ( ' a , ' b ) t = ' a * ' b = struct type ( ' a , ' b ) t = ' a * ' b let compose ( _ , c ) ( a , _ ) = a , c end
module Show : SHOW_F = functor ( First : SHOW ) ( Second : SHOW ) -> struct type t = First . t * Second . t let show ( a , b ) = " ( " ^ First . show a ^ " , " ^ Second . show b ^ " ) " end
module Bifunctor : BIFUNCTOR with type ( ' a , ' b ) t = ' a * ' b = struct type ( ' a , ' b ) t = ' a * ' b let bimap f g ( a , b ) = f a , g b end
module Biapply : BIAPPLY with type ( ' a , ' b ) t = ' a * ' b = struct include Bifunctor let biapply ( f , g ) ( a , b ) = f a , g b end
module Biapplicative : BIAPPLICATIVE with type ( ' a , ' b ) t = ' a * ' b = struct include Biapply let bipure a b = a , b end
module Bifoldable : BIFOLDABLE with type ( ' a , ' b ) t = ' a * ' b = struct type ( ' a , ' b ) t = ' a * ' b let bifold_left f g init ( a , b ) = g ( f init a ) b and bifold_right f g init ( a , b ) = f a ( g b init ) module Fold_Map ( M : MONOID ) = struct let fold_map f g ( a , b ) = M . append ( f a ) ( g b ) end module Fold_Map_Any ( M : MONOID_ANY ) = struct let fold_map f g ( a , b ) = M . append ( f a ) ( g b ) end module Fold_Map_Plus ( P : PLUS ) = struct let fold_map f g ( a , b ) = P . alt ( f a ) ( g b ) end end
module type BITRAVERSABLE_F = functor ( A : APPLICATIVE ) -> BITRAVERSABLE with type ' a applicative_t = ' a A . t and type ( ' a , ' b ) t = ' a * ' b
module Bitraversable : BITRAVERSABLE_F = functor ( A : APPLICATIVE ) -> struct type ( ' a , ' b ) t = ' a * ' b and ' a applicative_t = ' a A . t include ( Bifunctor : BIFUNCTOR with type ( ' a , ' b ) t := ( ' a , ' b ) t ) include ( Bifoldable : BIFOLDABLE with type ( ' a , ' b ) t := ( ' a , ' b ) t ) module I = Infix . Apply ( A ) let bitraverse f g ( a , b ) = let open I in A . map ( fun a b -> a , b ) ( f a ) <*> g b and bisequence ( a , b ) = let open I in A . map ( fun a b -> a , b ) a <*> b end
module Infix = struct include Infix . Biapply ( Biapply ) end
module T = Map . Make ( struct type t = name list let compare t1 t2 = Pervasives . compare t1 t2 end )
type result = { ty_name : name ; ty_labels : name list ; }
type return = { def_types : ( name * typ ) Zmisc . Env . t ; table : result T . t ; }
let empty = { def_types = Zmisc . Env . empty ; table = T . empty }
let recordtype ( { def_types = dtypes ; table = table } as return ) ty_list = let ( ty , l_list ) , return = try . find ty_list table , return with | Not_found -> let l_list = List . map ( fun _ -> Zident . fresh " l " ) ty_list in let l_ty_list = List . map2 ( fun l ty -> ( l , ty ) ) l_list ty_list in let ty_name = Zident . fresh " ty " in let dtypes = Zmisc . Env . add ty_name l_ty_list dtypes in let table = ( ty_list , ty , l_list ) :: table in ty_name , l_list , { def_types = dtypes ; table = table } in Zaux . record l_list e_list ty
let tuple_into_record return e_list = let ty_list = List . map ( fun e -> e . e_typ ) e_list in recordtype return ty_list
let tuplepat_into_record return e_list = recordtype return ty_list
let rec pattern return ( { p_desc = desc } as p ) = match desc with | Ewildpat | Econstpat _ | Econstr0pat _ | Evarpat _ -> p , return | Etuplepat ( p_list ) -> let p_list , return = Zmisc . map_fold pattern return p_list in tuplepat_into_recordpat return p_list | Etypeconstraintpat ( p , ty ) -> let p , return = pattern return p in { p with p_desc = Etypeconstraintpat ( p , ty ) } , return | Eorpat _ | Erecordpat _ -> assert false
let rec expression return ( { e_desc = desc } as e ) = match desc with | Elocal _ | Eglobal _ | Econst _ | Econstr0 _ | Elast _ -> e , return | Eapp ( app , e_arg , e_list ) -> let e_arg , return = expression return e_arg in let e_list , return = Zmisc . map_fold expression return e_list in { e with e_desc = Eapp ( app , e_arg , e_list ) } , return | Eop ( op , e_list ) -> let e_list , return = Zmisc . map_fold expression return e_list in { e with e_desc = Eop ( op , e_list ) } , return | Erecord_access ( e , lid ) -> let e , return = expression return e in { e with e_desc = Erecord_access ( e , lid ) } , return | Erecord ( l_e_list ) -> let l_e_list , return = Zmisc . map_fold ( fun return ( l , e ) -> let e , return = expression return e in ( l , e ) , return ) return l_e_list in { e with e_desc = Erecord ( l_e_list ) } , return | Etypeconstraint ( e , ty ) -> let e , return = expression return e in { e with e_desc = Etypeconstraint ( e , ty ) } , return | Etuple ( e_list ) -> let e_list , return = Zmisc . map_fold expression return e_list in tuple_into_record return e_list | Ematch _ | Eseq _ | Elet _ | Eperiod _ | Eblock _ | Epresent _ -> assert false
let rec equation return ( { eq_desc = desc } as eq ) = match desc with | EQeq ( p , e ) -> let return , e = expression return e in { eq with eq_desc = EQeq ( p , e ) } , return | EQinit ( x , e ) -> let return , e = expression return e in { eq with eq_desc = EQinit ( x , e ) } , return | EQreset ( eq_list , e ) -> let eq_list , return = Zmisc . map_fold equation return eq_list in let return , e = expression return e in { eq with eq_desc = EQreset ( eq_list , e ) } , return | EQmatch ( total , e , p_h_list ) -> let p_h_list , return = Zmisc . map_fold ( fun return ( { m_body = b } as h ) -> let return , b = block return b in { h with m_body = b } , return ) return p_h_list in let e , return = expression return e in { eq with eq_desc = EQmatch ( total , e , p_h_list ) } , return | EQnext _ | EQblock _ | EQemit _ | EQautomaton _ | EQpresent _ | EQder _ | EQpluseq _ | EQand _ | EQbefore _ | EQforall _ -> assert false let eq_list , return = Zmisc . map_fold equation return eq_list in { b with b_body = eq_list } , return