Skip to content

Commit

Permalink
WIP System.IO
Browse files Browse the repository at this point in the history
  • Loading branch information
decioferreira committed Nov 23, 2024
1 parent ebca0be commit 272b0cd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html>

<head>
<meta charset="UTF-8">
<title>Main</title>
<script src="index.js"></script>
</head>

<body>
<script>
const app = Elm.Main.init({});
app.ports.sendHPutStr.subscribe(function (args) {
console.log(args);
app.ports.recvHPutStr.send(null);
})
app.ports.sendGetLine.subscribe(function () {
app.ports.recvGetLine.send("some string...");
})
</script>
</body>

</html>
18 changes: 18 additions & 0 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Main exposing (main)

import System.IO as IO exposing (IO)


main : IO.Program
main =
IO.run app


app : IO ()
app =
IO.pure 1
|> IO.fmap ((+) 2)
|> IO.fmap String.fromInt
|> IO.bind (IO.hPutStr IO.stdout)
|> IO.bind (\() -> IO.getLine)
|> IO.bind (\name -> IO.hPutStr IO.stdout ("Hello " ++ name))

0 comments on commit 272b0cd

Please sign in to comment.