Created
December 19, 2021 08:24
-
-
Save Sgeo/3da4fb5c7730da374357d484ec31d72e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
effect focus<a> | |
ctl focus(a : a): a | |
fun vl-fst(f: a -> focus<r> b): (((a, c)) -> focus<r> (b, c)) | |
fn(pair) | |
match pair | |
(a, c) -> (f(a), c) | |
fun vl-snd(f: a -> focus<r> b): (((c, a)) -> focus<r> (c, b)) | |
fn(pair) | |
match pair | |
(c, a) -> (c, f(a)) | |
// Allowing focus in the modifier might be a problem. Figure out how to get rid of it? | |
fun over(optic: ((a) -> focus<r> b) -> ((s) -> focus<r> t), modifier: (a -> b), target: s): t | |
with fun focus(a) | |
a | |
val large_modifier = optic(modifier) | |
large_modifier(target) | |
fun over-elim(a: a, action: (a -> focus<r> b)): b | |
with fun focus(a) | |
a | |
action(a) | |
fun get-elim(a: a, action: (a -> focus<r> b)): exn r | |
with handler { | |
brk focus(a) | |
a | |
return(a) | |
throw("No focus!") | |
} | |
action(a) | |
// Can't figure out how to type this! | |
// fun get(s: s, optic: ((a) -> focus<a> a) -> ((s) -> focus<b> a)): exn b | |
// get-elim(s, optic(focus)) | |
fun main() : console () | |
println("Hello, world!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment