Created
December 19, 2022 12:40
-
-
Save rupertlssmith/514f0a1997f26b1df714301f70e08685 to your computer and use it in GitHub Desktop.
Type hiding in Elm by using continuations.
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
module Existential exposing (add, impl, init, map, wrap) | |
impl : t -> (raise -> rep -> t) | |
impl constructor = | |
\raise rep -> constructor | |
wrap : (raise -> rep -> t) -> (raise -> rep -> (t -> q)) -> (raise -> rep -> q) | |
wrap method pipeline raise rep = | |
method raise rep |> pipeline raise rep | |
add : (rep -> t) -> (raise -> rep -> (t -> q)) -> (raise -> rep -> q) | |
add method pipeline raise rep = | |
method rep |> pipeline raise rep | |
map : (a -> b) -> (raise -> rep -> a) -> (raise -> rep -> b) | |
map op pipeline raise rep = | |
pipeline raise rep |> op | |
init : ((rep -> sealed) -> flags -> output) -> ((rep -> sealed) -> rep -> sealed) -> flags -> output | |
init initRep pipeline flags = | |
let | |
raise : rep -> sealed | |
raise rep = | |
pipeline raise rep | |
in | |
initRep raise flags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment