Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21525aa
commit 7713048
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- Click on the righthand screen and start pressing keys! | ||
|
||
import Char | ||
import Graphics.Element exposing (..) | ||
import Keyboard | ||
import Signal exposing (..) | ||
import String | ||
|
||
-- foldr : (Char -> b -> b) -> b -> String -> b | ||
-- foldp : (a -> state -> state) -> state -> Signal a -> Signal state | ||
-- foldp (\click total -> total + 1) 0 Mouse.clicks | ||
-- map : (a -> result) -> Signal a -> Signal result | ||
|
||
|
||
|
||
|
||
|
||
main : Signal Element | ||
main = Signal.map display state | ||
|
||
|
||
state: Signal String | ||
state = foldp String.cons "" chars | ||
|
||
chars: Signal String | ||
chars = map (\keycode -> toString <| Char.fromCode keycode ) Keyboard.presses | ||
|
||
|
||
display : String -> Element | ||
display str = | ||
flow right | ||
[ show "The current state is : " | ||
, show str | ||
] |