Send Beginners mailing list submissions to
        [email protected]

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
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Expected / Inferred mis-match and confused! (Daniel Fischer)
   2. Re:  Simple warp-based server (Christopher Done)
   3.  Options for creating a multiple select form via  Yesod
      (Michael Litchard)
   4. Re:  Simple warp-based server (Michael Xavier)
   5. Re:  Expected / Inferred mis-match and confused! (Sean Charles)
   6. Re:  Simple warp-based server (Christopher Done)
   7.  How to know which module my library belongs to ? (Adrien Haxaire)
   8. Re:  "Trinary" version of Either (Antoine Latter)


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

Message: 1
Date: Thu, 9 Jun 2011 18:55:06 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Expected / Inferred mis-match and
        confused!
To: [email protected]
Cc: Sean Charles <[email protected]>
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="us-ascii"

On Thursday 09 June 2011, 18:26:18, Sean Charles wrote:
> Here are the snippets of my code currently hurting my coding ulcer...
> 
> routes :: [Record] -> IO ()
> routes legodata = do
>    let all = foldl forwardRoutes M.empty legodata -- [Record]
>    return ()
> 
> 
> forwardRoutes :: M.Map String [String] -> Record -> M.Map String
> [String]
> forwardRoutes map row =
>    let key = row !! 0 in
>    let val = row !! 1 in
>    case lookup key map of

Ah, that needs to be M.lookup, without qualifying the call, it refers to 
Prelude.lookup :: Eq a => a -> [(a,b)] -> Maybe b

>      Nothing     -> M.insert key [val] map


>      Just routes -> M.insert key val:routes map

This needs parentheses, M.insert key (val:routes) map

> 
> I have spent a long time searching and reading and trying to fathom it 
> out from first principles but I cannot for the life of me figure out 
> where '[(Field, b)]' is coming from!

Prelude.lookup vs. Data.Map.lookup

> I can smell Field in there because 
> Record is typed as [Field], but a tuple? And what is 'b' ?
> 
> The 'inferred type' matches what I thought it should be in the error 
> message and I am right (I think) in stating that the 'expected type' is 
> what it actually got from the code at compile time?!
> 
> Help!
> 
> :)



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

Message: 2
Date: Thu, 9 Jun 2011 19:08:53 +0200
From: Christopher Done <[email protected]>
Subject: Re: [Haskell-beginners] Simple warp-based server
To: Michael Xavier <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

On 9 June 2011 17:45, Michael Xavier <[email protected]> wrote:

> Hi Haskell Beginners,
>
> I am writing a fairly simple app in haskell that will be used to support
> some Ruby on Rails apps at work. The gist of it is that it takes a JSON
> request and produces a JSON response. I've figured that strapping it to a
> web server will be the easiest way to allow our Rails apps to talk to it
> without worrying about IPC and all of that. I looked at yesod and snap and
> both seemed to be too much for what I'm asking. It seems to me that the best
> approach would be to write up an WAI interface, strap it to a Warp server
> and call it a day.
>

I don't think it matters much what server you use for this type of service.
We've been using FastCGI for two fairly large JSON services (11K lines) for
a year with no problems. Warp and Snap are also sufficient. Is speed a big
concern? Otherwise the iterators will be a bit pointless. I'm with you on
forgeting about worrying about the server for this type of service and
calling it a day.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110609/b755a45e/attachment-0001.htm>

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

Message: 3
Date: Thu, 9 Jun 2011 10:29:54 -0700
From: Michael Litchard <[email protected]>
Subject: [Haskell-beginners] Options for creating a multiple select
        form via        Yesod
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

I'm trying to create a multiple select form, as illustrated on the following:
http://api.jquery.com/selected-selector/

Here's the options I see possible:

(1) Write a jQuery widget.
(2) Use plain javascript via Julius
(3) Use the low-level functions in Yesod.Form to write a widget
(4) Use a pre-existing function that does what I need, but am not
aware of this functionality

(1) has appeal as it looks like something small I can contribute to
the project. It will take me some extra time to figure out the
details. But, I had a look at the other jQuery widgets and they seem
to provide an approachable model to follow.

(2) This looks like the most straight-forward approach. I'm just
learning javascript so would have to figure out how to capture values
in Haskell from the form.

(3) This looks like the most difficult way. I don't think I know
enough about the low-level functions in Yesod.Form to be able to
accomplish this in a timely manner.

(4) This is the best scenario. There's already a way to do this right
now, and I just haven't identified it. If this is the case, I would
appreciate being pointed in the right direction.

Until informed otherwise, I'm evaluating options 1 and 2. All feedback
welcomed. Thanks to all who made Yesod possible.



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

Message: 4
Date: Thu, 9 Jun 2011 11:01:30 -0700
From: Michael Xavier <[email protected]>
Subject: Re: [Haskell-beginners] Simple warp-based server
To: [email protected]
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

>
> I don't think it matters much what server you use for this type of service.
> We've been using FastCGI for two fairly large JSON services (11K lines) for
> a year with no problems. Warp and Snap are also sufficient. Is speed a big
> concern? Otherwise the iterators will be a bit pointless. I'm with you on
> forgeting about worrying about the server for this type of service and
> calling it a day.
>
>
I'm fairly ignorant of how FastCGI works and only slightly less ignorant
about Warp after reading a paper on it by Michael Snoyman, but concurrent
connections is a concern. I haven't been able to test the app with a large
dataset but the algorithm is something along the lines of O^2 complexity so
some requests may take much longer than others. One of my concerns then is
that the server should be able to handle concurrent connections well and not
let any long-running requests starve/block the others. If FastCGI forks off
one process per connection, that would likely be a lot of overhead for the
simple case.

One thing I can say is that my app as it exists now must parse the entire
request body JSON before it starts acting on it. I hope that clears things
up.

-- 
Michael Xavier
http://www.michaelxavier.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110609/e344696c/attachment-0001.htm>

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

Message: 5
Date: Thu, 09 Jun 2011 19:01:49 +0100
From: Sean Charles <[email protected]>
Subject: Re: [Haskell-beginners] Expected / Inferred mis-match and
        confused!
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Thanks every, Daniel, the list at large... I have finally solved my 
issue and moved on... for the record my function now looks like this:

forwardRoutes :: M.Map String [String]
                  -> Record
                  -> M.Map String [String]
forwardRoutes map row =
   let key = row !! 0 in
   let val = row !! 1 in
   case M.lookup key map of
     Nothing     -> M.insert key [val] map
     Just routes -> M.insert key (nub (val:routes)) map

and does just what I want!
The thing I ha failed to see was using Prelude.lookup instead of 
M.lookup and some errant ().

I know nub is 'potentially inefficient' but the source data set is 
reasonably small and the script only has to run three to four times a 
year so "So what!"

Just one thing: IF the error message had printed out the Prelude.lookup 
in the error message, that would have been incredibly useful! Is that a 
command line switch I haven't come across perhaps ?

Thanks again.
Sean.





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

Message: 6
Date: Thu, 9 Jun 2011 20:11:13 +0200
From: Christopher Done <[email protected]>
Subject: Re: [Haskell-beginners] Simple warp-based server
To: Michael Xavier <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

On 9 June 2011 20:01, Michael Xavier <[email protected]> wrote:

> I'm fairly ignorant of how FastCGI works and only slightly less ignorant
>> about Warp after reading a paper on it by Michael Snoyman, but concurrent
>> connections is a concern. I haven't been able to test the app with a large
>> dataset but the algorithm is something along the lines of O^2 complexity so
>> some requests may take much longer than others. One of my concerns then is
>> that the server should be able to handle concurrent connections well and not
>> let any long-running requests starve/block the others. If FastCGI forks off
>> one process per connection, that would likely be a lot of overhead for the
>> simple case.
>>
>
Well, FastCGI is a single process (maybe you're thinking of CGI). For the
FastCGI library you specify how to handle a request, like with forkIO or
forkOS or merely id. Thus one request can sit churning while others are
responding and finishing. Not sure whether Warp is concurrent or
asynchronous. Perhaps someone can fill us in?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110609/61d4f748/attachment-0001.htm>

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

Message: 7
Date: Thu, 09 Jun 2011 22:49:01 +0200
From: Adrien Haxaire <[email protected]>
Subject: [Haskell-beginners] How to know which module my library
        belongs to ?
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello,

I am writing a finite element method (FEM) library. Nothing serious at 
the moment, this is my home project to help me learn Haskell and add my 
stone to the community, as I did not find such a library.

For the JSON library, in the folder of the library, there are some files 
for the licence and cabal, a directoy for the tests and a directory 
Text, in which there is the directory JSON and the file JSON.hs.

I don't know which module should be the parent of my library. I think it 
is in Mathematics and Physics, like MEEPS for example, but I prefer to 
ask here to be sure.

Many thanks in advance,
Adrien




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

Message: 8
Date: Thu, 9 Jun 2011 16:06:11 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] "Trinary" version of Either
To: Christopher Howard <[email protected]>
Cc: Beginners Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Thu, Jun 9, 2011 at 3:58 PM, Christopher Howard
<[email protected]> wrote:
> My preference would be: just like a regular Monad either instance from mtl,
> except that the Middle value also bypasses the bound function. My semantics
> would be: left value represents error, right reprents normal results, and
> middle represents results that are not erroneous but that prevent further
> calculations. I have some idea of how this could be used to chain together
> actions and avoid messy branching in code.
>

>From your description, 'Either (Either errType earlyExitType) a'
should do everything you want, then, with the default monad instance
for either.

You would need something like:

> myThrowError = Left . Left
> haltExecution = Left . Right

Antoine

> Sent from my HTC
>
> ----- Reply message -----
> From: "Antoine Latter" <[email protected]>
> Date: Thu, Jun 9, 2011 8:18 am
> Subject: [Haskell-beginners] "Trinary" version of Either
> To: "Christopher Howard" <[email protected]>
> Cc: "Haskell Beginners" <[email protected]>
>
>
> On Thu, Jun 9, 2011 at 10:15 AM, Christopher Howard
> <[email protected]> wrote:
>> Is there a Haskell package out there that provides a "trinary" version
>> of Either, i.e., allowing three values instead of two? I can see how
>> that would be very handy. Defining one obviously wouldn't be difficult,
>> but it would be helpful if someone else had already developed Monad
>> bindings and other related stuff.
>>
>
> What would the Monad operations do?
>
>> --
>> frigidcode.com
>> theologia.indicium.us
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
>
>



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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 36, Issue 26
*****************************************

Reply via email to