summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Sosa <gnusosa@gnusosa.net>2020-03-21 18:41:35 -0700
committerCarlos Sosa <gnusosa@gnusosa.net>2020-03-21 18:41:35 -0700
commitd235a180b642f62b19acc582166255f015d38438 (patch)
treebb022c82c393ff475b3e726e8ff4b0a4b79a2683
parentf3e001044829f4864360df87a69695cb962e5d36 (diff)
Move to stack src directory
-rw-r--r--src/ch2/Main.hs (renamed from ex2/Main.hs)0
-rw-r--r--src/ch2/Shape.hs (renamed from ex2/Shape.hs)0
-rw-r--r--src/ch3/Main.hs4
-rw-r--r--src/ch3/SimpleGraphics.hs24
4 files changed, 28 insertions, 0 deletions
diff --git a/ex2/Main.hs b/src/ch2/Main.hs
index 74d0054..74d0054 100644
--- a/ex2/Main.hs
+++ b/src/ch2/Main.hs
diff --git a/ex2/Shape.hs b/src/ch2/Shape.hs
index d1f9e2f..d1f9e2f 100644
--- a/ex2/Shape.hs
+++ b/src/ch2/Shape.hs
diff --git a/src/ch3/Main.hs b/src/ch3/Main.hs
new file mode 100644
index 0000000..217f50d
--- /dev/null
+++ b/src/ch3/Main.hs
@@ -0,0 +1,4 @@
+import SimpleGraphics
+
+main :: IO ()
+main = main0
diff --git a/src/ch3/SimpleGraphics.hs b/src/ch3/SimpleGraphics.hs
new file mode 100644
index 0000000..5e160a7
--- /dev/null
+++ b/src/ch3/SimpleGraphics.hs
@@ -0,0 +1,24 @@
+module SimpleGraphics where
+
+import Graphics.SOE
+
+main0 = runGraphics (
+ do w <- openWindow "My First Graphics Program" (300,300)
+ drawInWindow w (text (100,200) "HelloGraphicsWolrd")
+ spaceClose w
+ )
+
+spaceClose :: Window -> IO ()
+spaceClose w = do k <- getKey w
+ if k == ' ' then closeWindow w
+ else spaceClose w
+getLine :: IO String
+getLine = do c <- getChar
+ if c == '\n' then return ""
+ else do v <- SimpleGraphics.getLine
+ return (c:v)
+
+putStr :: String -> IO ()
+putStr [] = return ()
+putStr (x:xs) = do putChar x
+ SimpleGraphics.putStr xs