Skip to content

Instantly share code, notes, and snippets.

@LeifW
Last active March 5, 2020 19:53
Show Gist options
  • Save LeifW/25c8113e2b8a11d95ff1a05153db4f14 to your computer and use it in GitHub Desktop.
Save LeifW/25c8113e2b8a11d95ff1a05153db4f14 to your computer and use it in GitHub Desktop.
Purescript UI w/ Flare
module Main where
import Prelude
import Effect (Effect)
import Flare (UI, string, runFlare)
greet :: String -> String
greet name = "Hello, " <> name
flare :: UI String
flare = greet <$> string "Please enter your name:" "Your name"
main :: Effect Unit
main = runFlare "controls" "output" flare
{ name = "my-project"
, dependencies = [ "console", "effect", "flare" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
@LeifW
Copy link
Author

LeifW commented Mar 5, 2020

Apparently my code translated into:

var Data_Functor = $PS["Data.Functor"];
var Flare = $PS["Flare"];                
var greet = function (name) {
    return "Hello, " + name;
};
var flare = Data_Functor.map(Flare.functorUI)(greet)(Flare.string("Please enter your name:")("Your name"));
var main = Flare.runFlare("controls")("output")(flare);

Which seems like a pleasantly direct mapping to javascript of the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment