Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Beginners Digest, Vol 57, Issue 12 (Francisco Guti?rrez) 2. Re: Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' (emacstheviking) ---------------------------------------------------------------------- Message: 1 Date: Sun, 10 Mar 2013 18:08:49 -0500 From: Francisco Guti?rrez <fgutiers2...@yahoo.com> Subject: Re: [Haskell-beginners] Beginners Digest, Vol 57, Issue 12 To: "beginners@haskell.org" <beginners@haskell.org> Message-ID: <6a76f254-e63a-4a8e-8bbf-20aafa560...@yahoo.com> Content-Type: text/plain; charset=utf-8 Enviado desde mi iPhone El 10/03/2013, a las 18:00, beginners-requ...@haskell.org escribi?: > Send Beginners mailing list submissions to > beginners@haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.haskell.org/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-requ...@haskell.org > > You can reach the person managing the list at > beginners-ow...@haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Re: Create new value for given type (Kim-Ee Yeoh) > 2. Re: Performance problem with Haskell/OpenGL/GLFW > (Jesper S?rnesj?) > 3. Re: Performance problem with Haskell/OpenGL/GLFW > (Jesper S?rnesj?) > 4. Re: Performance problem with Haskell/OpenGL/GLFW > (Hollister Herhold) > 5. Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual > type `IO ()' (emacstheviking) > 6. Re: Trouble in (Fast)CGI land: matching `CGIT IO a0' with > actual type `IO ()' (David McBride) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 11 Mar 2013 03:48:33 +0700 > From: Kim-Ee Yeoh <k...@atamo.com> > Subject: Re: [Haskell-beginners] Create new value for given type > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell <beginners@haskell.org> > Message-ID: > <CAPY+ZdRYVFG=z=aACXJQ7p4t39Cc_dx6c4M_zKq8uiBSxF1=7...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Mon, Mar 11, 2013 at 1:33 AM, Kim-Ee Yeoh <k...@atamo.com> wrote: >> class MyTheory a where >> someKindOfChoice :: a -> [a] -> [a] > > Whoops, that should be [a] -> [a], or perhaps more usefully [a] -> a. > > In a way, such a function constructively /proves/ that the type is > infinite. Of course, it has to satisfy a bunch of conditions. You can > sort of see how going down this path leads naturally to Coq and Agda. > > -- Kim-Ee > > > > ------------------------------ > > Message: 2 > Date: Mon, 11 Mar 2013 08:11:36 +1100 > From: Jesper S?rnesj? <sarne...@gmail.com> > Subject: Re: [Haskell-beginners] Performance problem with > Haskell/OpenGL/GLFW > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell <beginners@haskell.org> > Message-ID: > <calex+wiznqhryvatoaeencmoecnfmyg56+h2ak0uvdkd+l-...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Mon, Mar 11, 2013 at 1:31 AM, Andrey Yankin <yankin...@gmail.com> wrote: >> AFAIK glfw-b uses its own version of glfw which is built during setup. >> There is a makefile inside the package. > > GLFW-b does indeed bundle its own version of the GLFW C library [1], > version 2.7.3 as of right now. This is why it can be installed without > first installing the C library on your system. > > However, this is not the library that Test2.hs (nor test2.c) links > against. In fact, that program does not use GLFW-b at all, but rather > simply declares a few entry points with C calling convention that > should be there at linking time. I did this only to be able to rule > out any problem with GLFW-b. > >> Can't reproduce this error on Arch. > > I got the change to run my code on a Windows 7 machine, and didn't see > the problem there either. This seems to be specific to Haskell on Mac > OS X. > > -- > Jesper S?rnesj? > http://jesper.sarnesjo.org/ > > [1] https://github.com/bsl/GLFW-b/tree/master/glfw > > > > ------------------------------ > > Message: 3 > Date: Mon, 11 Mar 2013 08:23:01 +1100 > From: Jesper S?rnesj? <sarne...@gmail.com> > Subject: Re: [Haskell-beginners] Performance problem with > Haskell/OpenGL/GLFW > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell <beginners@haskell.org> > Message-ID: > <CALex+Wh2n6=92v1wngpuxzxju855pglwaw3rrxau+nlrcrq...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On Mon, Mar 11, 2013 at 7:17 AM, Hollister Herhold <hollis...@fafoh.com> > wrote: >> Okay, I think I just figured this out. Well, HOW to get it working with the >> accelerated renderer. >> >> I was wondering a simple way to check renderer info so I ran glxinfo. This >> (automatically) fired up X11, and then on a hunch I re-ran Test2 with X11 >> running and got this: >> >> hhmacbook:~/Development/haskell/OpenGL:57> ./Test2 >> hardware >> (2,7,7) >> (3,2,0) >> hhmacbook:~/Development/haskell/OpenGL:58> >> >> AH HA! I then quit X11 and re-ran Test2, and got this: >> >> hhmacbook:~/Development/haskell/OpenGL:58> ./Test2 >> software >> (2,7,7) >> (3,2,0) >> hhmacbook:~/Development/haskell/OpenGL:59> >> >> SO- If you want the accelerated renderer, you need to have X11 running. >> >> Now, I have no idea WHY this is the case, but there you go. >> >> Hope this helps. > > This lead me down an interesting path. > > First, I should explain that my machine, like most newish Macs, has > two graphics cards. In my case, a discrete Nvidia GeForce GT 330M, and > an integrated Intel chip. The former is better, but the latter uses > less power, and the system is supposed to switch between them > automatically. > > I used gfxCardStatus [1] to show which card was in use. When I ran > test2.c, the system briefly switched to the discrete card. However, > when I ran Test2.hs, the system kept using the integrated chip the > whole time. Presumably, the Intel chip lacks a hardware implementation > of OpenGL 3.2, which causes the system to fall back to a software > renderer. I then used gfxCardStatus to force the system to *always* > use the discrete card and - boom! - this time Test2.hs received a > hardware renderer! > > So it seems that the problem is a) Mac OS X-specific, or possibly > specific to systems with multiple graphics cards, b) related to > triggering the *switch* to the better graphics card. I don't yet > understand why the C program triggers a switch, while the Haskell > program does not, but I'll keep investigating. > > Thank you all very much for your help! > > -- > Jesper S?rnesj? > http://jesper.sarnesjo.org/ > > [1] http://gfx.io > > > > ------------------------------ > > Message: 4 > Date: Sun, 10 Mar 2013 18:27:56 -0400 > From: Hollister Herhold <hollis...@fafoh.com> > Subject: Re: [Haskell-beginners] Performance problem with > Haskell/OpenGL/GLFW > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell <beginners@haskell.org> > Message-ID: <24e1a52d-cb7b-49a0-a0ec-9a932dbed...@fafoh.com> > Content-Type: text/plain; charset=utf-8 > > I guess running X11 forces use of the NVidia chip. Interesting. > > -Hollister > > On Mar 10, 2013, at 5:23 PM, Jesper S?rnesj? <sarne...@gmail.com> wrote: > >> On Mon, Mar 11, 2013 at 7:17 AM, Hollister Herhold <hollis...@fafoh.com> >> wrote: >>> Okay, I think I just figured this out. Well, HOW to get it working with the >>> accelerated renderer. >>> >>> I was wondering a simple way to check renderer info so I ran glxinfo. This >>> (automatically) fired up X11, and then on a hunch I re-ran Test2 with X11 >>> running and got this: >>> >>> hhmacbook:~/Development/haskell/OpenGL:57> ./Test2 >>> hardware >>> (2,7,7) >>> (3,2,0) >>> hhmacbook:~/Development/haskell/OpenGL:58> >>> >>> AH HA! I then quit X11 and re-ran Test2, and got this: >>> >>> hhmacbook:~/Development/haskell/OpenGL:58> ./Test2 >>> software >>> (2,7,7) >>> (3,2,0) >>> hhmacbook:~/Development/haskell/OpenGL:59> >>> >>> SO- If you want the accelerated renderer, you need to have X11 running. >>> >>> Now, I have no idea WHY this is the case, but there you go. >>> >>> Hope this helps. >> >> This lead me down an interesting path. >> >> First, I should explain that my machine, like most newish Macs, has >> two graphics cards. In my case, a discrete Nvidia GeForce GT 330M, and >> an integrated Intel chip. The former is better, but the latter uses >> less power, and the system is supposed to switch between them >> automatically. >> >> I used gfxCardStatus [1] to show which card was in use. When I ran >> test2.c, the system briefly switched to the discrete card. However, >> when I ran Test2.hs, the system kept using the integrated chip the >> whole time. Presumably, the Intel chip lacks a hardware implementation >> of OpenGL 3.2, which causes the system to fall back to a software >> renderer. I then used gfxCardStatus to force the system to *always* >> use the discrete card and - boom! - this time Test2.hs received a >> hardware renderer! >> >> So it seems that the problem is a) Mac OS X-specific, or possibly >> specific to systems with multiple graphics cards, b) related to >> triggering the *switch* to the better graphics card. I don't yet >> understand why the C program triggers a switch, while the Haskell >> program does not, but I'll keep investigating. >> >> Thank you all very much for your help! >> >> -- >> Jesper S?rnesj? >> http://jesper.sarnesjo.org/ >> >> [1] http://gfx.io >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners > > > > ------------------------------ > > Message: 5 > Date: Sun, 10 Mar 2013 22:40:04 +0000 > From: emacstheviking <obji...@gmail.com> > Subject: [Haskell-beginners] Trouble in (Fast)CGI land: matching `CGIT > IO a0' with actual type `IO ()' > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell <beginners@haskell.org> > Message-ID: > <caeieuukezkevyzsdwpcet-fn94-n8optodouknhgkwkihfz...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > I am writing a stop-motion capture application using AngularJS and it's > going OK. I was inspired to do so after installing "IPCamera" on my phone > and Sony tablet. A typical IPCamera session lives on an internal address > like this, this example will turn on the LED on the camera: > > http://192.168.0.5:8080/enabletorch > > Just because I can (or so I thought), I decided to write a tiny little > FastCGI application in Haskell to act as a proxy using the PATH_INFO > variable. This means that in to my Javascript code I have this code in a > service file: > > angular.module('stomoServices', ['ngResource']). > factory( > 'IPCamera', > function($resource, urlIPCameraAPI) { > return $resource( > urlIPCameraAPI, > {}, { > ledOn: { method: 'GET', params: {featureReq: 'enabletorch' }}, > ledOff: { method: 'GET', params: {featureReq: 'disabletorch' }}, > focusOn: { method: 'GET', params: {featureReq: 'focus' }}, > focusOff: { method: 'GET', params: {featureReq: 'nofocus'}} > }); > }); > > and I then issue commands like "IPCamera.ledOn()" etc. All very nice except > that it doesn't work yet because I can't get the worlds seemingly simplest > CGI application to compile yet! Here is the code that I have, it could be > "cleared up" but this is what I have so far: > > main :: IO () > main = runFastCGI . handleErrors $ do > command <- getVar "PATH_INFO" > case command of > Nothing -> > outputError 400 "Missing IPCamera instruction (PATH_INFO)" [] > Just cmd -> > ipCamExec (tail cmd) >> output "OK" -- tail drops the "/" > where > ipCamExec :: String -> IO () > ipCamExec url = do > simpleHTTP (getRequest url) -- don't want or need response. > return () -- to match the return type or so I thought. > > and the error message I cannot seem to understand as it fills me with > monadic fear which I can't get out of: > > ipcamera.hs:16:7: > Couldn't match expected type `CGIT IO a0' with actual type `IO ()' > In the return type of a call of `ipCamExec' > In the first argument of `(>>)', namely `ipCamExec (tail cmd)' > In the expression: ipCamExec (tail cmd) >> output "OK" > > Please could some kind souls explain to me in simple terms just what is > going on and why I am close to tears right now? I have read the definitions > of CGIResult and CGI and they leave me cold. I am trying to understand > monads more but at times like this I once again realise what a complete > rank beginner I am! > > Thanks. > Sean. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://www.haskell.org/pipermail/beginners/attachments/20130310/8e43f9c0/attachment-0001.htm> > > ------------------------------ > > Message: 6 > Date: Sun, 10 Mar 2013 18:59:56 -0400 > From: David McBride <toa...@gmail.com> > Subject: Re: [Haskell-beginners] Trouble in (Fast)CGI land: matching > `CGIT IO a0' with actual type `IO ()' > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell <beginners@haskell.org> > Message-ID: > <can+tr406r9tdavjxhdcrujzm-mmuucdjufwwy9rcqd1gzmd...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Your ipCamExec is IO (), but you are running it in the CGI a monad which is > a type alias for CGIT IO a. CGIT is an instance of MonadIO, so try liftIO > ipCamExec. liftIO has a type MonadIO m => IO a -> m a, which means that if > you replace m with CGIT IO, you would get IO a -> CGIT IO a, which is > exactly what you need. > > On Sun, Mar 10, 2013 at 6:40 PM, emacstheviking <obji...@gmail.com> wrote: > >> I am writing a stop-motion capture application using AngularJS and it's >> going OK. I was inspired to do so after installing "IPCamera" on my phone >> and Sony tablet. A typical IPCamera session lives on an internal address >> like this, this example will turn on the LED on the camera: >> >> http://192.168.0.5:8080/enabletorch >> >> Just because I can (or so I thought), I decided to write a tiny little >> FastCGI application in Haskell to act as a proxy using the PATH_INFO >> variable. This means that in to my Javascript code I have this code in a >> service file: >> >> angular.module('stomoServices', ['ngResource']). >> factory( >> 'IPCamera', >> function($resource, urlIPCameraAPI) { >> return $resource( >> urlIPCameraAPI, >> {}, { >> ledOn: { method: 'GET', params: {featureReq: 'enabletorch' }}, >> ledOff: { method: 'GET', params: {featureReq: 'disabletorch' }}, >> focusOn: { method: 'GET', params: {featureReq: 'focus' }}, >> focusOff: { method: 'GET', params: {featureReq: 'nofocus'}} >> }); >> }); >> >> and I then issue commands like "IPCamera.ledOn()" etc. All very nice >> except that it doesn't work yet because I can't get the worlds seemingly >> simplest CGI application to compile yet! Here is the code that I have, it >> could be "cleared up" but this is what I have so far: >> >> main :: IO () >> main = runFastCGI . handleErrors $ do >> command <- getVar "PATH_INFO" >> case command of >> Nothing -> >> outputError 400 "Missing IPCamera instruction (PATH_INFO)" [] >> Just cmd -> >> ipCamExec (tail cmd) >> output "OK" -- tail drops the "/" >> where >> ipCamExec :: String -> IO () >> ipCamExec url = do >> simpleHTTP (getRequest url) -- don't want or need response. >> return () -- to match the return type or so I thought. >> >> and the error message I cannot seem to understand as it fills me with >> monadic fear which I can't get out of: >> >> ipcamera.hs:16:7: >> Couldn't match expected type `CGIT IO a0' with actual type `IO ()' >> In the return type of a call of `ipCamExec' >> In the first argument of `(>>)', namely `ipCamExec (tail cmd)' >> In the expression: ipCamExec (tail cmd) >> output "OK" >> >> Please could some kind souls explain to me in simple terms just what is >> going on and why I am close to tears right now? I have read the definitions >> of CGIResult and CGI and they leave me cold. I am trying to understand >> monads more but at times like this I once again realise what a complete >> rank beginner I am! >> >> Thanks. >> Sean. >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://www.haskell.org/pipermail/beginners/attachments/20130310/a193df67/attachment.htm> > > ------------------------------ > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > End of Beginners Digest, Vol 57, Issue 12 > ***************************************** ------------------------------ Message: 2 Date: Sun, 10 Mar 2013 23:21:27 +0000 From: emacstheviking <obji...@gmail.com> Subject: Re: [Haskell-beginners] Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Message-ID: <caeieuujzgfcfrprbsmccbcrdrq8hklb4xprlqgdsdjz+bno...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" David, At times like this I think am not even fit to code PHP for my day job. I am going to have to read that very carefully when I wake up tomorrow. Thanks. On 10 March 2013 22:59, David McBride <toa...@gmail.com> wrote: > Your ipCamExec is IO (), but you are running it in the CGI a monad which > is a type alias for CGIT IO a. CGIT is an instance of MonadIO, so try > liftIO ipCamExec. liftIO has a type MonadIO m => IO a -> m a, which means > that if you replace m with CGIT IO, you would get IO a -> CGIT IO a, which > is exactly what you need. > > On Sun, Mar 10, 2013 at 6:40 PM, emacstheviking <obji...@gmail.com> wrote: > >> I am writing a stop-motion capture application using AngularJS and it's >> going OK. I was inspired to do so after installing "IPCamera" on my phone >> and Sony tablet. A typical IPCamera session lives on an internal address >> like this, this example will turn on the LED on the camera: >> >> http://192.168.0.5:8080/enabletorch >> >> Just because I can (or so I thought), I decided to write a tiny little >> FastCGI application in Haskell to act as a proxy using the PATH_INFO >> variable. This means that in to my Javascript code I have this code in a >> service file: >> >> angular.module('stomoServices', ['ngResource']). >> factory( >> 'IPCamera', >> function($resource, urlIPCameraAPI) { >> return $resource( >> urlIPCameraAPI, >> {}, { >> ledOn: { method: 'GET', params: {featureReq: 'enabletorch' }}, >> ledOff: { method: 'GET', params: {featureReq: 'disabletorch' }}, >> focusOn: { method: 'GET', params: {featureReq: 'focus' }}, >> focusOff: { method: 'GET', params: {featureReq: 'nofocus'}} >> }); >> }); >> >> and I then issue commands like "IPCamera.ledOn()" etc. All very nice >> except that it doesn't work yet because I can't get the worlds seemingly >> simplest CGI application to compile yet! Here is the code that I have, it >> could be "cleared up" but this is what I have so far: >> >> main :: IO () >> main = runFastCGI . handleErrors $ do >> command <- getVar "PATH_INFO" >> case command of >> Nothing -> >> outputError 400 "Missing IPCamera instruction (PATH_INFO)" [] >> Just cmd -> >> ipCamExec (tail cmd) >> output "OK" -- tail drops the "/" >> where >> ipCamExec :: String -> IO () >> ipCamExec url = do >> simpleHTTP (getRequest url) -- don't want or need response. >> return () -- to match the return type or so I thought. >> >> and the error message I cannot seem to understand as it fills me with >> monadic fear which I can't get out of: >> >> ipcamera.hs:16:7: >> Couldn't match expected type `CGIT IO a0' with actual type `IO ()' >> In the return type of a call of `ipCamExec' >> In the first argument of `(>>)', namely `ipCamExec (tail cmd)' >> In the expression: ipCamExec (tail cmd) >> output "OK" >> >> Please could some kind souls explain to me in simple terms just what is >> going on and why I am close to tears right now? I have read the definitions >> of CGIResult and CGI and they leave me cold. I am trying to understand >> monads more but at times like this I once again realise what a complete >> rank beginner I am! >> >> Thanks. >> Sean. >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130310/ce0c72d6/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 57, Issue 13 *****************************************