[Haskell-beginners] Beginners Digest, Vol 57, Issue 12
Francisco Gutiérrez
fgutiers2002 at yahoo.com
Mon Mar 11 00:08:49 CET 2013
Enviado desde mi iPhone
El 10/03/2013, a las 18:00, beginners-request at haskell.org escribió:
> Send Beginners mailing list submissions to
> beginners at 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-request at haskell.org
>
> You can reach the person managing the list at
> beginners-owner at 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 <ky3 at 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 at haskell.org>
> Message-ID:
> <CAPY+ZdRYVFG=z=aACXJQ7p4t39Cc_dx6c4M_zKq8uiBSxF1=7A at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Mon, Mar 11, 2013 at 1:33 AM, Kim-Ee Yeoh <ky3 at 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? <sarnesjo at 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 at haskell.org>
> Message-ID:
> <CALex+WiznQHRYvAtOAeENcMOecnfmYg56+h2AK0uvdKD+L-YBg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Mon, Mar 11, 2013 at 1:31 AM, Andrey Yankin <yankin013 at 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? <sarnesjo at 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 at haskell.org>
> Message-ID:
> <CALex+Wh2n6=92v1wnGpuxzXJU855PGLWAw3RrxAu+nLrCRq1zw at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Mon, Mar 11, 2013 at 7:17 AM, Hollister Herhold <hollister at 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 <hollister at 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 at haskell.org>
> Message-ID: <24E1A52D-CB7B-49A0-A0EC-9A932DBEDF73 at 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? <sarnesjo at gmail.com> wrote:
>
>> On Mon, Mar 11, 2013 at 7:17 AM, Hollister Herhold <hollister at 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 at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sun, 10 Mar 2013 22:40:04 +0000
> From: emacstheviking <objitsu at 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 at haskell.org>
> Message-ID:
> <CAEiEuUKEZkEvyZSdWPCeT-fN94-n8OPtOdoUKnHgkwKihfZ3GA at 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 <toad3k at 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 at haskell.org>
> Message-ID:
> <CAN+Tr406r9tDavJxHdcRuJzm-mmUUcDJUFWwY9RCQd1gZmDYFQ at 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 <objitsu at 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 at 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
> End of Beginners Digest, Vol 57, Issue 12
> *****************************************
More information about the Beginners
mailing list