Open plt-amy opened 4 years ago
let x <|> y = match x with | Some _ -> x | None -> y let chainr1 p op = let rec scan = let! x = p rest x and rest x = ( let! f = op let! y = scan pure (f x y) ) <|> pure x scan
This code oughtta be compiled something like:
local scan, rest scan = bind(dict)(p)(function(x) return rest(x) end) rest = ...
But, nah, amc eta-contracts the fun x -> rest x into just rest, which forces it early, which results in attempt to call nil.
fun x -> rest x
rest
attempt to call nil
local scan, rest scan = _greater_greater_equals(p, rest) rest = function(x)
Repro here
This code oughtta be compiled something like:
But, nah, amc eta-contracts the
fun x -> rest x
into justrest
, which forces it early, which results inattempt to call nil
.