Skip to content

Instantly share code, notes, and snippets.

@mheinzel
Created February 12, 2017 10:06
Show Gist options
  • Save mheinzel/3b874b8239739d22ec7405a81d6922fd to your computer and use it in GitHub Desktop.
Save mheinzel/3b874b8239739d22ec7405a81d6922fd to your computer and use it in GitHub Desktop.
mheinzel@mh-tp-ubu:~/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo$ stack repl
Warning: File listed in gloss-demo.cabal file does not exist: README.md
Warning: File listed in gloss-demo.cabal file does not exist: README.md
gloss-demo-0.1.0.0: configure (lib + exe)
Configuring gloss-demo-0.1.0.0...
gloss-demo-0.1.0.0: initial-build-steps (lib + exe)
Warning: File listed in gloss-demo.cabal file does not exist: README.md
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: gloss-demo
Using main module: 1. Package `gloss-demo' component exe:gloss-demo-exe with main-is file: /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Lib ( /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.
[2 of 2] Compiling Main ( /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs, interpreted )
Ok, modules loaded: Lib, Main.
Loaded GHCi configuration from /tmp/ghci10787/ghci-script
*Main Lib> let disp = InWindow "test" (480,320) (0,0)
<interactive>:1:12: error:
Data constructor not in scope:
InWindow :: [Char] -> (Integer, Integer) -> (Integer, Integer) -> t
*Main Lib> import Graphics.Gloss
*Main Lib Graphics.Gloss> let disp = InWindow "test" (480,320) (0,0)
*Main Lib Graphics.Gloss> :t disp
disp :: Display
*Main Lib Graphics.Gloss> display disp red (text "Hello World")
mheinzel@mh-tp-ubu:~/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo$ stack repl
Warning: File listed in gloss-demo.cabal file does not exist: README.md
Warning: File listed in gloss-demo.cabal file does not exist: README.md
gloss-demo-0.1.0.0: initial-build-steps (lib + exe)
Warning: File listed in gloss-demo.cabal file does not exist: README.md
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: gloss-demo
Using main module: 1. Package `gloss-demo' component exe:gloss-demo-exe with main-is file: /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Lib ( /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.
[2 of 2] Compiling Main ( /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs, interpreted )
Ok, modules loaded: Lib, Main.
Loaded GHCi configuration from /tmp/ghci10892/ghci-script
*Main Lib> let disp = InWindow "test" (480,320) (0,0)
<interactive>:1:12: error:
Data constructor not in scope:
InWindow :: [Char] -> (Integer, Integer) -> (Integer, Integer) -> t
*Main Lib> import Graphics.Gloss
*Main Lib Graphics.Gloss> let disp = InWindow "test" (480,320) (0,0)
*Main Lib Graphics.Gloss> animate disp red circle
mheinzel@mh-tp-ubu:~/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo$ stack repl
Warning: File listed in gloss-demo.cabal file does not exist: README.md
Warning: File listed in gloss-demo.cabal file does not exist: README.md
gloss-demo-0.1.0.0: initial-build-steps (lib + exe)
Warning: File listed in gloss-demo.cabal file does not exist: README.md
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: gloss-demo
Using main module: 1. Package `gloss-demo' component exe:gloss-demo-exe with main-is file: /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Lib ( /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.
[2 of 2] Compiling Main ( /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs, interpreted )
Ok, modules loaded: Lib, Main.
Loaded GHCi configuration from /tmp/ghci10970/ghci-script
*Main Lib> import Graphics.Gloss
*Main Lib Graphics.Gloss> let disp = InWindow "test" (480,320) (0,0)
*Main Lib Graphics.Gloss>
*Main Lib Graphics.Gloss> let initState = 0
*Main Lib Graphics.Gloss> let toPicture = text . show
*Main Lib Graphics.Gloss> let updateTime _ st = st
*Main Lib Graphics.Gloss> :{
*Main Lib Graphics.Gloss| updateEvent (EventKey KeyUp Down _ _) c = c + 1
*Main Lib Graphics.Gloss| updateEvent (EventKey KeyDown Down _ _) c = c - 1
*Main Lib Graphics.Gloss| updateEvent _ c = c
*Main Lib Graphics.Gloss| :}
<interactive>:8:14: error:
Not in scope: data constructor ‘EventKey’
<interactive>:8:23: error: Not in scope: data constructor ‘KeyUp’
<interactive>:8:29: error: Not in scope: data constructor ‘Down’
<interactive>:9:14: error:
Not in scope: data constructor ‘EventKey’
<interactive>:9:23: error: Not in scope: data constructor ‘KeyDown’
<interactive>:9:31: error: Not in scope: data constructor ‘Down’
*Main Lib Graphics.Gloss> import Graphics.Gloss.Interface
<no location info>: error:
Could not find module ‘Graphics.Gloss.Interface’
Perhaps you meant
Graphics.GL.OML.Interlace (needs flag -package-key OpenGLRaw-3.2.4.0@OpenGLRaw-3.2.4.0-JDyGgOXR61GG549SwmWm2Q)
*Main Lib Graphics.Gloss> import Graphics.Gloss.Interface.IO.Game
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game> :{
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| updateEvent (EventKey KeyUp Down _ _) c = c + 1
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| updateEvent (EventKey KeyDown Down _ _) c = c - 1
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| updateEvent _ c = c
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| :}
<interactive>:15:23: error:
• Couldn't match expected type ‘Key’ with actual type ‘SpecialKey’
• In the pattern: KeyUp
In the pattern: EventKey KeyUp Down _ _
In an equation for ‘updateEvent’:
updateEvent (EventKey KeyUp Down _ _) c = c + 1
<interactive>:16:23: error:
• Couldn't match expected type ‘Key’ with actual type ‘SpecialKey’
• In the pattern: KeyDown
In the pattern: EventKey KeyDown Down _ _
In an equation for ‘updateEvent’:
updateEvent (EventKey KeyDown Down _ _) c = c - 1
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game> :{
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| updateEvent (EventKey (SpecialKey KeyUp) Down _ _) c = c + 1
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| updateEvent (EventKey (SpecialKey KeyDown) Down _ _) c = c - 1
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| updateEvent _ c = c
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game| :}
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game> :t updateEvent
updateEvent :: Num a => Event -> a -> a
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game> play disp (dark red) 30 init
init initState
*Main Lib Graphics.Gloss Graphics.Gloss.Interface.IO.Game> play disp (dark red) 30 initState toPicture updateEvent updateTime
mheinzel@mh-tp-ubu:~/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment