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:  Having fun with yesod, and a few questions   came up.
      (Michael Litchard)
   2. Re:  Having fun with yesod, and a few questions   came up.
      (Michael Snoyman)
   3. Re:  Having fun with yesod, and a few questions   came up.
      (Michael Litchard)
   4.  Re: why is something different within a function when it
      comes out? (prad)


----------------------------------------------------------------------

Message: 1
Date: Thu, 15 Jul 2010 10:39:45 -0700
From: Michael Litchard <mich...@schmong.org>
Subject: Re: [Haskell-beginners] Having fun with yesod, and a few
        questions       came up.
To: beginners@haskell.org
Message-ID:
        <aanlktilv7j5_y8p9e2sknj3shf534advk7raz1pys...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Okay this is what I have so far, concerning what I need to do on the
Haskell end of things to get it working with lighttpd.

As an example, I will use blog.lhs from the yesod tutorial

All that's left now is the main function. Yesod is built on top of
WAI, so you can use any WAI handler you wish. For the tutorials, we'll
use the basicHandler that comes built-in with Yesod: it serves content
via CGI if the appropriate environment variables are available,
otherwise with simpleserver.

> main :: IO ()
> main = do
>   entries <- loadEntries
>   basicHandler 3000 $ Blog entries

This brings into sharp relief my ignorance on how to use hackage. I
tried to investigate hackage looking for some WAI handler that would
get me what I want. Namely, turning this example into a fastCGI
application that lighttpd could use.

So this generates two questions. How would one use hackage to find a
WAI handler to use for fastCGI?
What would be an example of a WAI handler I could use with yesod?

Thanks for making it possible for guys like me to do this.

On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman <mich...@snoyman.com> wrote:
>
>
> On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard <mich...@schmong.org>
> wrote:
>>
>> I'm playing with yesod http://docs.yesodweb.com/yesod/,  and I have a
>> few questions:
>>
>> Here's an excerpt from yesod/tutorial/i18n.lhs
>>
>> **NOTE: This tutorial requires the development version of Yesod
>> (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has
>> instructions on setting up your environment.**
>>
>> Where is $root?
>> I thought it was where yesod-examples-0.4.0 was installed. But if this
>> is the case, I'm not finding these instructions. This makes me think I
>> am confused about the directory $root represents.
>>
> Sorry about the $root stuff, it's an artifact from the web site. I use the
> same code base for the yesod-examples package and the tutorials on the site
> to make sure everything compiles properly. In any event, the line in
> question is out-of-date and needs to be removed: 0.4.0 has been officially
> released, so you just need a cabal install yesod to get started.
>>
>> I was playing around with the code and made some changes. Here is the
>> line in question, with the complete code below for context.
>>
>> > instance Yesod I18N where
>> >     approot _ = ""
>>
>> This does what I expect it to do, it runs the program when I open up
>> http://my.blog.server/
>>
>> however, I wanted to see what would happen if I played around with it
>> a little bit. I want the same program to run when I point my browser
>> to http://my.blog.server/blog
>>
>> so I made this change
>> >     approot _ = "/blog"
>>
>> but now when I point my browser to http://my.blog.server/blog it gets
>> re-written to http:/my.blog.server/blog/blog
>> and then this error message
>> Not Found
>> /blog/blog
>>
>> Not sure what is going on here, could someone enlighten me?
>>
>>
> The approot function is used for *rendering* routes. This has no affect on
> where Yesod *listens* to requests. For example, you could put approot _ =
> "http://haskell.org";, but you wouldn't be able to respond to requests for
> that domain. Nonetheless, URLs generated by Yesod would then point to
> haskell.org.
> Basically, the only time to get fancy with approot is when you're doing URL
> rewriting for (Fast)CGI hosted applications. When you use a standalone
> server, you'll always* be serving from the root of the domain, and so the
> value of approot should just be that domain name.
> * Of course, there's always exceptions.
> You might look at the documentation[1] where it explains when it's
> permissible to use an empty string for the value of approot.
> Michael
> [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot


------------------------------

Message: 2
Date: Thu, 15 Jul 2010 21:06:56 +0300
From: Michael Snoyman <mich...@snoyman.com>
Subject: Re: [Haskell-beginners] Having fun with yesod, and a few
        questions       came up.
To: Michael Litchard <mich...@schmong.org>
Cc: beginners@haskell.org
Message-ID:
        <aanlktilplmpppkmpjkwccyvosaqevxzsdf6gp0kif...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Regarding the incompleteness of fastcgi tutorial: I'm not quite sure what
you mean. The deploying section[1] gives information on how to configure
lighttpd to run a compiled Yesod application, *not* on how to write that
application. The tutorials show you how to write a Yesod application

The only thing missing now is your other question: which handler to use. The
answer to wai-handler-fastcgi[2]. It's built on top of the libfcgi C
library, so you'll need to make sure you have that installed. A previous
version was built on the direct-fastcgi[3] package, but I found that to have
considerably lower performance. If people are interested in a
wai-handler-direct-fastcgi, let me know, I'll release it.

Anyway, the function you're probably looking for in Yesod is toWaiApp[4],
which produces an Application. You can then pass that Application to the
wai-handler-fastcgi run function, and you'll have a fastcgi executable.

If you think it will be useful, I can package up a sample application with a
lighttpd config file. And if anyone out there knows how to write config
files for other servers, that would be a nice addition as well.

Michael

[1] http://docs.yesodweb.com/yesod/deploying.html
<http://docs.yesodweb.com/yesod/deploying.html>[2]
http://hackage.haskell.org/package/wai-handler-fastcgi
[3] http://hackage.haskell.org/package/direct-fastcgi
[4] http://docs.yesodweb.com/haddock/yesod/Yesod-Dispatch.html#v%3AtoWaiApp

On Thu, Jul 15, 2010 at 8:39 PM, Michael Litchard <mich...@schmong.org>wrote:

> Okay this is what I have so far, concerning what I need to do on the
> Haskell end of things to get it working with lighttpd.
>
> As an example, I will use blog.lhs from the yesod tutorial
>
> All that's left now is the main function. Yesod is built on top of
> WAI, so you can use any WAI handler you wish. For the tutorials, we'll
> use the basicHandler that comes built-in with Yesod: it serves content
> via CGI if the appropriate environment variables are available,
> otherwise with simpleserver.
>
> > main :: IO ()
> > main = do
> >   entries <- loadEntries
> >   basicHandler 3000 $ Blog entries
>
> This brings into sharp relief my ignorance on how to use hackage. I
> tried to investigate hackage looking for some WAI handler that would
> get me what I want. Namely, turning this example into a fastCGI
> application that lighttpd could use.
>
> So this generates two questions. How would one use hackage to find a
> WAI handler to use for fastCGI?
> What would be an example of a WAI handler I could use with yesod?
>
> Thanks for making it possible for guys like me to do this.
>
> On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman <mich...@snoyman.com>
> wrote:
> >
> >
> > On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard <mich...@schmong.org>
> > wrote:
> >>
> >> I'm playing with yesod http://docs.yesodweb.com/yesod/,  and I have a
> >> few questions:
> >>
> >> Here's an excerpt from yesod/tutorial/i18n.lhs
> >>
> >> **NOTE: This tutorial requires the development version of Yesod
> >> (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has
> >> instructions on setting up your environment.**
> >>
> >> Where is $root?
> >> I thought it was where yesod-examples-0.4.0 was installed. But if this
> >> is the case, I'm not finding these instructions. This makes me think I
> >> am confused about the directory $root represents.
> >>
> > Sorry about the $root stuff, it's an artifact from the web site. I use
> the
> > same code base for the yesod-examples package and the tutorials on the
> site
> > to make sure everything compiles properly. In any event, the line in
> > question is out-of-date and needs to be removed: 0.4.0 has been
> officially
> > released, so you just need a cabal install yesod to get started.
> >>
> >> I was playing around with the code and made some changes. Here is the
> >> line in question, with the complete code below for context.
> >>
> >> > instance Yesod I18N where
> >> >     approot _ = ""
> >>
> >> This does what I expect it to do, it runs the program when I open up
> >> http://my.blog.server/
> >>
> >> however, I wanted to see what would happen if I played around with it
> >> a little bit. I want the same program to run when I point my browser
> >> to http://my.blog.server/blog
> >>
> >> so I made this change
> >> >     approot _ = "/blog"
> >>
> >> but now when I point my browser to http://my.blog.server/blog it gets
> >> re-written to http:/my.blog.server/blog/blog
> >> and then this error message
> >> Not Found
> >> /blog/blog
> >>
> >> Not sure what is going on here, could someone enlighten me?
> >>
> >>
> > The approot function is used for *rendering* routes. This has no affect
> on
> > where Yesod *listens* to requests. For example, you could put approot _ =
> > "http://haskell.org";, but you wouldn't be able to respond to requests
> for
> > that domain. Nonetheless, URLs generated by Yesod would then point to
> > haskell.org.
> > Basically, the only time to get fancy with approot is when you're doing
> URL
> > rewriting for (Fast)CGI hosted applications. When you use a standalone
> > server, you'll always* be serving from the root of the domain, and so the
> > value of approot should just be that domain name.
> > * Of course, there's always exceptions.
> > You might look at the documentation[1] where it explains when it's
> > permissible to use an empty string for the value of approot.
> > Michael
> > [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot
> _______________________________________________
> 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/20100715/a420df89/attachment-0001.html

------------------------------

Message: 3
Date: Thu, 15 Jul 2010 11:18:39 -0700
From: Michael Litchard <mich...@schmong.org>
Subject: Re: [Haskell-beginners] Having fun with yesod, and a few
        questions       came up.
To: Michael Snoyman <mich...@snoyman.com>
Cc: beginners@haskell.org
Message-ID:
        <aanlktikwr6xetp-x4gs6jmcnvoletqiey9pzxwcd6...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Yes, thank you. It would be useful for you to package up a sample
application with a lighttpd config file. I would appreciate that.


On Thu, Jul 15, 2010 at 11:06 AM, Michael Snoyman <mich...@snoyman.com> wrote:
> Regarding the incompleteness of fastcgi tutorial: I'm not quite sure what
> you mean. The deploying section[1] gives information on how to configure
> lighttpd to run a compiled Yesod application, *not* on how to write that
> application. The tutorials show you how to write a Yesod application
> The only thing missing now is your other question: which handler to use. The
> answer to wai-handler-fastcgi[2]. It's built on top of the libfcgi C
> library, so you'll need to make sure you have that installed. A previous
> version was built on the direct-fastcgi[3] package, but I found that to have
> considerably lower performance. If people are interested in a
> wai-handler-direct-fastcgi, let me know, I'll release it.
> Anyway, the function you're probably looking for in Yesod is toWaiApp[4],
> which produces an Application. You can then pass that Application to the
> wai-handler-fastcgi run function, and you'll have a fastcgi executable.
> If you think it will be useful, I can package up a sample application with a
> lighttpd config file. And if anyone out there knows how to write config
> files for other servers, that would be a nice addition as well.
> Michael
>
> [1] http://docs.yesodweb.com/yesod/deploying.html
> [2] http://hackage.haskell.org/package/wai-handler-fastcgi
> [3] http://hackage.haskell.org/package/direct-fastcgi
> [4] http://docs.yesodweb.com/haddock/yesod/Yesod-Dispatch.html#v%3AtoWaiApp
>
> On Thu, Jul 15, 2010 at 8:39 PM, Michael Litchard <mich...@schmong.org>
> wrote:
>>
>> Okay this is what I have so far, concerning what I need to do on the
>> Haskell end of things to get it working with lighttpd.
>>
>> As an example, I will use blog.lhs from the yesod tutorial
>>
>> All that's left now is the main function. Yesod is built on top of
>> WAI, so you can use any WAI handler you wish. For the tutorials, we'll
>> use the basicHandler that comes built-in with Yesod: it serves content
>> via CGI if the appropriate environment variables are available,
>> otherwise with simpleserver.
>>
>> > main :: IO ()
>> > main = do
>> >   entries <- loadEntries
>> >   basicHandler 3000 $ Blog entries
>>
>> This brings into sharp relief my ignorance on how to use hackage. I
>> tried to investigate hackage looking for some WAI handler that would
>> get me what I want. Namely, turning this example into a fastCGI
>> application that lighttpd could use.
>>
>> So this generates two questions. How would one use hackage to find a
>> WAI handler to use for fastCGI?
>> What would be an example of a WAI handler I could use with yesod?
>>
>> Thanks for making it possible for guys like me to do this.
>>
>> On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman <mich...@snoyman.com>
>> wrote:
>> >
>> >
>> > On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard <mich...@schmong.org>
>> > wrote:
>> >>
>> >> I'm playing with yesod http://docs.yesodweb.com/yesod/,  and I have a
>> >> few questions:
>> >>
>> >> Here's an excerpt from yesod/tutorial/i18n.lhs
>> >>
>> >> **NOTE: This tutorial requires the development version of Yesod
>> >> (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has
>> >> instructions on setting up your environment.**
>> >>
>> >> Where is $root?
>> >> I thought it was where yesod-examples-0.4.0 was installed. But if this
>> >> is the case, I'm not finding these instructions. This makes me think I
>> >> am confused about the directory $root represents.
>> >>
>> > Sorry about the $root stuff, it's an artifact from the web site. I use
>> > the
>> > same code base for the yesod-examples package and the tutorials on the
>> > site
>> > to make sure everything compiles properly. In any event, the line in
>> > question is out-of-date and needs to be removed: 0.4.0 has been
>> > officially
>> > released, so you just need a cabal install yesod to get started.
>> >>
>> >> I was playing around with the code and made some changes. Here is the
>> >> line in question, with the complete code below for context.
>> >>
>> >> > instance Yesod I18N where
>> >> >     approot _ = ""
>> >>
>> >> This does what I expect it to do, it runs the program when I open up
>> >> http://my.blog.server/
>> >>
>> >> however, I wanted to see what would happen if I played around with it
>> >> a little bit. I want the same program to run when I point my browser
>> >> to http://my.blog.server/blog
>> >>
>> >> so I made this change
>> >> >     approot _ = "/blog"
>> >>
>> >> but now when I point my browser to http://my.blog.server/blog it gets
>> >> re-written to http:/my.blog.server/blog/blog
>> >> and then this error message
>> >> Not Found
>> >> /blog/blog
>> >>
>> >> Not sure what is going on here, could someone enlighten me?
>> >>
>> >>
>> > The approot function is used for *rendering* routes. This has no affect
>> > on
>> > where Yesod *listens* to requests. For example, you could put approot _
>> > =
>> > "http://haskell.org";, but you wouldn't be able to respond to requests
>> > for
>> > that domain. Nonetheless, URLs generated by Yesod would then point to
>> > haskell.org.
>> > Basically, the only time to get fancy with approot is when you're doing
>> > URL
>> > rewriting for (Fast)CGI hosted applications. When you use a standalone
>> > server, you'll always* be serving from the root of the domain, and so
>> > the
>> > value of approot should just be that domain name.
>> > * Of course, there's always exceptions.
>> > You might look at the documentation[1] where it explains when it's
>> > permissible to use an empty string for the value of approot.
>> > Michael
>> > [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>
>


------------------------------

Message: 4
Date: Thu, 15 Jul 2010 12:12:19 -0700
From: prad <p...@towardsfreedom.com>
Subject: [Haskell-beginners] Re: why is something different within a
        function when it comes out?
To: beginners@haskell.org
Message-ID: <20100715121219.7f222...@gom>
Content-Type: text/plain; charset=ISO-8859-1

On Thu, 15 Jul 2010 09:39:39 +0200
Chaddaï Fouché <chaddai.fou...@gmail.com> wrote:

> Though you must be aware
> that parsing html (or any markup language) properly with regexp is
> just impossible in general and you can only get crude and fragile
> approximations.
i never realized that since my needs have been pretty simple and
python's re has done things nicely.

> There are proper html parsing libraries on hackage if
> your needs become too complex for simple regexp to handle.
i found tagsoup a while ago and i'm trying to learn how to use it
better. it's a bit of an overkill for what i'm doing here which
probably can be done even without regex - something i'm thinking about.
thx.

-- 
In friendship,
prad

                                      ... with you on your journey
Towards Freedom
http://www.towardsfreedom.com (website)
Information, Inspiration, Imagination - truly a site for soaring I's


------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 25, Issue 37
*****************************************

Reply via email to