Running GLUT code in GHCi yields NSInternalInconsistencyException
I tried running some `GLUT` code in macOS Sierra (Version 10.12.5 (16F73)) and ran into a strange error. If you're willing to use `cabal-install`, you can just do this:
```
$ cabal install GLFW-0.5.2.5
```
And run this module in with `runghc`:
```hs
-- GLUT.hs
module Main where
import Graphics.UI.GLUT (($=), getArgsAndInitialize, createWindow, displayCallback, mainLoop)
main :: IO ()
main = do
(_progName, _args) <- getArgsAndInitialize
_window <- createWindow "Hello World"
displayCallback $= return ()
mainLoop
```
```
$ runghc GLUT.hs
2017-05-19 12:03:02.199 ghc[24628:669385] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: nextEventMatchingMask should only be called from the Main Thread!
```
On the other hand, compiling and running the executable works without issue.
Alternatively, you can compile the attached files, which require no dependencies:
```
$ ghc HsGLUT.c GLUT2.hs
[1 of 1] Compiling Main ( GLUT2.hs, GLUT2.o )
Linking GLUT2 ...
$ ghci HsGLUT.o GLUT2.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/rscott/.ghci
[1 of 1] Compiling Main ( GLUT2.hs, interpreted )
Ok, modules loaded: Main.
λ> main
2017-05-19 12:06:15.365 ghc[24671:670166] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: nextEventMatchingMask should only be called from the Main Thread!
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Running GLUT code in GHCi yields NSInternalInconsistencyException","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I tried running some `GLUT` code in macOS Sierra (Version 10.12.5 (16F73)) and ran into a strange error. If you're willing to use `cabal-install`, you can just do this:\r\n\r\n{{{\r\n$ cabal install GLFW-0.5.2.5\r\n}}}\r\n\r\nAnd run this module in with `runghc`:\r\n\r\n{{{#!hs\r\n-- GLUT.hs\r\nmodule Main where\r\n\r\nimport Graphics.UI.GLUT (($=), getArgsAndInitialize, createWindow, displayCallback, mainLoop)\r\n\r\nmain :: IO ()\r\nmain = do\r\n (_progName, _args) <- getArgsAndInitialize\r\n _window <- createWindow \"Hello World\"\r\n displayCallback $= return ()\r\n mainLoop\r\n}}}\r\n\r\n{{{\r\n$ runghc GLUT.hs\r\n2017-05-19 12:03:02.199 ghc[24628:669385] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: nextEventMatchingMask should only be called from the Main Thread!\r\n}}}\r\n\r\nOn the other hand, compiling and running the executable works without issue.\r\n\r\nAlternatively, you can compile the attached files, which require no dependencies:\r\n\r\n{{{\r\n$ ghc HsGLUT.c GLUT2.hs\r\n[1 of 1] Compiling Main ( GLUT2.hs, GLUT2.o )\r\nLinking GLUT2 ...\r\n\r\n$ ghci HsGLUT.o GLUT2.hs\r\nGHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /Users/rscott/.ghci\r\n[1 of 1] Compiling Main ( GLUT2.hs, interpreted )\r\nOk, modules loaded: Main.\r\nλ> main\r\n2017-05-19 12:06:15.365 ghc[24671:670166] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: nextEventMatchingMask should only be called from the Main Thread!\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->
issue