You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have the default instance of ~re/~onError in REPL. However the following naive definition:
data Error (effect E) = { raise : {type T} -> Unit ->[E] T }
handle {effect=RE} err = Error { raise = effect () / _ => () }
let ~onError = err.raise
have a huge drawback: when we type [].hdErr, the REPL would exit immediately. The problem can be solved at library level, by adding the following file (ReplUtils.fram) to the standard library:
pub data ReplUtils (effect E) =
{ raise : {type T} -> Unit ->[E] T
, commit : Unit ->[E] Unit
}
pub handle {effect=ReplRE} repl = ReplUtils
{ raise = effect () / _ => fn snapshot =>
printStrLn "Runtime Error!";
match snapshot with
| None => ()
| Some f => f ()
end
, commit = effect () / r => fn _ =>
let rec snapshot () = r () (Some snapshot) in
snapshot ()
}
return x => fn _ => x
finally c => c None
let _ = repl.commit ()
pub let ~onError = repl.raise
but this would not solve all the problems:
> import List ;;
> import open ReplUtils ;;
> let foo x = x ;;
> [].hdErr ;;
: a
Runtime Error!
> foo 42 ;;
<stdin>:1:1-3: fatal error: Unbound variable foo
>
To do it correctly, we have to call repl.commit method after each REPL command, but this requires changes in the type-checker (or desugaring)
The text was updated successfully, but these errors were encountered:
It would be nice to have the default instance of
~re
/~onError
in REPL. However the following naive definition:have a huge drawback: when we type
[].hdErr
, the REPL would exit immediately. The problem can be solved at library level, by adding the following file (ReplUtils.fram) to the standard library:but this would not solve all the problems:
To do it correctly, we have to call
repl.commit
method after each REPL command, but this requires changes in the type-checker (or desugaring)The text was updated successfully, but these errors were encountered: