@@ -113,71 +113,6 @@ let transform_under_supply n loc status fn args =
113113 {[\ x y -> (\a b c -> g a b c) x y]}
114114 {[ \a b -> \c -> g a b c ]}
115115*)
116- (* * if arity = 0 then
117- begin match fn with
118- | Lfunction {params = [_]; body}
119- ->
120- compile_lambda cxt
121- (Lam.function_
122- ~arity:0
123- ~kind:Curried
124- ~params:[]
125- ~body)
126- | _ ->
127- let wrapper, new_fn =
128- match fn with
129- | Lvar _
130- | Lprim {primitive = Pfield _ ; args = [Lglobal_module _]; _} ->
131- None, fn
132- | _ ->
133- let partial_arg = Ext_ident.create Literals.partial_arg in
134- Some partial_arg, Lam.var partial_arg
135- in
136- let cont =
137- (Lam.function_ ~arity:0
138- ~kind:Curried ~params:[]
139- ~body:(
140- Lam.apply new_fn
141- [Lam.unit]
142- Location.none App_na
143- )) in
144- begin match wrapper with
145- | None ->
146- compile_lambda cxt cont
147- | Some partial_arg
148- ->
149- compile_lambda cxt (Lam.let_ Strict partial_arg fn cont )
150- end
151- end
152- else
153- begin match fn with
154- | Lam.Lfunction{arity = len; kind; params = args; body}
155- ->
156- if len = arity then
157- compile_lambda cxt fn
158- else if len > arity then
159- let params, rest = Ext_list.split_at arity args in
160- compile_lambda cxt
161- (Lam.function_
162- ~arity
163- ~kind ~params
164- ~body:(Lam.function_ ~arity:(len - arity)
165- ~kind ~params:rest ~body)
166- )
167- else (* len < arity *)
168- compile_lambda cxt
169- (Lam_eta_conversion.transform_under_supply arity
170- Location.none App_na
171- fn [] )
172- (* let extra_args = Ext_list.init (arity - len) (fun _ -> (Ident.create Literals.param)) in *)
173- (* let extra_lambdas = Ext_list.map (fun x -> Lam.var x) extra_args in *)
174- (* Lam.Lfunction (kind, Ext_list.append extra_args args , body ) *)
175-
176- | _ ->
177- compile_lambda cxt
178- (Lam_eta_conversion.transform_under_supply arity
179- Location.none App_na fn [] )
180- end *)
181116
182117
183118(* * Unsafe function, we are changing arity here, it should be applied
@@ -207,7 +142,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
207142 let wrapper, new_fn =
208143 match fn with
209144 | Lvar _
210- | Lprim {primitive = Pfield _ ; args = [Lglobal_module _]; _ }
145+ | Lprim {primitive = Pfield (_, Fld_module _) ; args = [Lglobal_module _ | Lvar _]; _ }
211146 ->
212147 None , fn
213148 | _ ->
@@ -243,7 +178,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
243178 let wrapper, new_fn =
244179 match fn with
245180 | Lvar _
246- | Lprim {primitive = Pfield _ ; args = [ Lglobal_module _] ; _} ->
181+ | Lprim {primitive = Pfield ( _ , Fld_module _ ) ; args = [ Lglobal_module _ | Lvar _ ] ; _ } ->
247182 None , fn
248183 | _ ->
249184 let partial_arg = Ext_ident. create Literals. partial_arg in
@@ -292,7 +227,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
292227 let wrapper, new_fn =
293228 match fn with
294229 | Lvar _
295- | Lprim {primitive = Pfield _ ; args = [ Lglobal_module _] ; _} ->
230+ | Lprim {primitive = Pfield ( _ , Fld_module _ ) ; args = [ Lglobal_module _ | Lvar _ ] ; _ } ->
296231 None , fn
297232 | _ ->
298233 let partial_arg = Ext_ident. create Literals. partial_arg in
@@ -323,7 +258,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
323258 let wrapper, new_fn =
324259 match fn with
325260 | Lvar _
326- | Lprim {primitive = Pfield _ ; args = [Lglobal_module _]; _ }
261+ | Lprim {primitive = Pfield (_, Fld_module _) ; args = [Lglobal_module _ | Lvar _]; _ }
327262 ->
328263 None , fn
329264 | _ ->
0 commit comments