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:  Type error in sub-function (???)
   2. Re:  Haskell in the Digital Humanities (Ren?@gmail)
   3.  Question on Lazy IO (???)
   4. Re:  Question on Lazy IO (Dan Serban)
   5. Re:  Question on Lazy IO (Dan Serban)
   6. Re:  Question on Lazy IO (Santtu Keskinen)


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

Message: 1
Date: Wed, 23 Jul 2014 23:45:04 +0900
From: ??? <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Type error in sub-function
Message-ID:
        <calmycjqnpzd_59t3gblo4z-akjywwkr0butuaomhdjg296m...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Thank you, Brandon.
I changed the code like belows and it works.

                       ('x':'x':name2) -> do vv <- case value of
                                                      "client_ip_addr" ->
return $ clientIp request
                                                      "now" -> do utcTime
<- currentUTCTime
                                                                  return $
formatRFC1123 utcTime
                                                      _ -> return value
                                              let prev = clientReqHdr obj
                                              return obj { clientReqHdr =
((name2, vv) : prev) }



2014-07-23 23:22 GMT+09:00 Brandon Allbery <[email protected]>:

>
> On Wed, Jul 23, 2014 at 10:18 AM, ??? <[email protected]> wrote:
>
>>                         ('x':'x':name2) -> return obj { clientReqHdr =
>> ((name2, vv) : prev) }
>>                            where prev = clientReqHdr obj
>>                                  vv = case value of
>>                                         "client_ip_addr" -> clientIp
>> request
>>                                         "now" -> do utcTime <-
>> currentUTCTime
>>                                                     return $
>> formatRFC1123 utcTime
>>                                         _ -> value
>>                         _ -> return obj
>>
>> However, above code does not compile also :-(
>> *Main> :l test
>>  [1 of 1] Compiling Main             ( test.hs, interpreted )
>>
>> test.hs:101:64:
>>     Couldn't match expected type `[t0]' with actual type `IO UTCTime'
>>     In a stmt of a 'do' block: utcTime <- currentUTCTime
>>      In the expression:
>>       do { utcTime <- currentUTCTime;
>>            return $ formatRFC1123 utcTime }
>>     In a case alternative:
>>         "now"
>>           -> do { utcTime <- currentUTCTime;
>>                   return $ formatRFC1123 utcTime }
>> Failed, modules loaded: none.
>>
>> Obviously outer do-block is inside IO monad, as the type of scanQuery is
>> Request -> IO Object. But GHC puts inner do-block (in "now" case)  inside
>> list monad,
>> doesn't it? Why does ghc look for List monad?
>>
>
> Because you're treating vv as a pure value when you use it, so ghc looks
> for a way to treat it as a monad and concludes that it is a List. If you
> want it to be in IO, you need to use <- on its result, not use it directly.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> [email protected]
> [email protected]
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140723/9d0c1a89/attachment-0001.html>

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

Message: 2
Date: Wed, 23 Jul 2014 17:23:35 +0200
From: "Ren?@gmail" <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Haskell in the Digital Humanities
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Dear Niels-Oliver,

having some relation to DH and working in my student's job with 
(dirty-tagsoup) XML.

Struck by Haskells beauty and clearness of coding but also aware of the 
rather deep and technical type abstractions and combinatorics which are 
still hard to grasp for me, I also felt unsure about following the 
Haskell road. Still clinging on to Haskell because:

a) bespoken clearness of code of Haskell I miss too hard when looking on 
other languages code

b) elegance of Parser-Combinators (well this seems not really an 
argument because they are ported to many other languages, but I also 
suspect something might be lost, because you do not get the full 
customizability of functions and operators like in Haskell in other langs)

c) stemming from the same Parser-Combinator vein: PANDOC: is there a 
better text conversion tool, which is so well maintained and so easy 
(well yes, some knowledge needed -> see learning tipps) to extend

d) I don't know much about robust code in other languages, but then 
again I had so much input by Haskell blogs and tutorials, that the idea 
that type safety and testing functions in isolation might be a good one 
has stuck. So although you probably will not interface with a nuclear 
power plant in your DH coding, I think robustness could be an argument too.

So the elegance of code and the safety of the program are very general 
pro-arguments for Haskell. Text handling capabilities through 
Parser-Combinators are really handy. Still for text-munging to produce a 
desired output for D3.js all this might seem overkill and to be honest I 
wouldn't want to parse tagsoup with Haskell either (but only because I 
know the benefits of a specialized text-processing-toolbox like TUSTEP 
[http://www.tustep.uni-tuebingen.de/tustep_eng.html]).

On the other hand, if you have a well formed XML there a enough 
XML-tools for haskell which produce a neat Haskell data structure which 
in turn you can work at with nice pure functions. Also there are enough 
possibilities to get these structures out into Javascript (Fay,...). 
(javascript? I also find elm-lang.org very compelling.)

So for now my solution is to have Haskell as an important side-project. 
I still have to go through the "Write Yourself A Scheme" [1] which is 
said to give the needed exposure to some abstract types so that one can 
digest the theory behind those much better, but I hope by then the 
scariness of the abunding type system will abate a bit more. There's 
also a new book about data anlysis, which advertises "Recipes for every 
stage of data analysis, from collection to visualization" [2].

Interfacing with C?
At least from my superficial obervance of my cabal installs 
Foreign.PointerC (or so) is by no means an exception. Don't know about 
Python, though.

Well, anyway good to know, someone has similar worries like me. Good luck!

Cheers,
Ren? Tobner

[1] http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours
[2] http://www.packtpub.com/haskell-data-analysis-cookbook/book

On 22.07.2014 14:00, [email protected] wrote:
> The question is simple and was raised by many people before, probably 
> everyone who began with another language and at some point got to know 
> Haskell: Should I learn Haskell?



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

Message: 3
Date: Thu, 24 Jul 2014 15:07:23 +0900
From: ??? <[email protected]>
To: beginners <[email protected]>
Subject: [Haskell-beginners] Question on Lazy IO
Message-ID:
        <calmycjrorkuhk0po6whgo14p6vnbjqkkc4mg58ela1ckxmi...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi, all.

Haskell's lazy IO causes below program to
write back "ECHO result" to the user
even if he doesn't give any input to the program.

test1 :: IO ()
test1 = do
  l <- fmap lines getContents
  putStrLn "ECHO result"
  putStr $ unlines l

If the client logic, that is the part for feeding data to this program
and wait for the response, expect the server logic to respond
only after all the client's request data are feed to the server logic,
the behaviour could be problematic.

I'm now writing simple web server, as you might guess, and
my web server responds "HTTP/1.1" before any client's request
are given. I'm using hGetContents and web server's logic is
basically same with above code skeleton.

How can I tell the program to respond data only after all the
requests are feed? Any directions are welcomed.
Thanks.

Chul-Woong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140724/e2cba2ad/attachment-0001.html>

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

Message: 4
Date: Thu, 24 Jul 2014 10:25:58 +0300
From: Dan Serban <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question on Lazy IO
Message-ID:
        <cahapvscsgo2wsgxxqusxv04pdhp2wexf-g8qfjrbvbad6vt...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi Chul-Woong,

$ pwd | ./testprog
ECHO result
/tmp

Your program works as you expect if you pipe some contents via STDIN.
This is testprog.hs:
main :: IO ()
main = do
  l <- fmap lines getContents
  putStrLn "ECHO result"
  putStr $ unlines l

-Dan


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

Message: 5
Date: Thu, 24 Jul 2014 10:47:23 +0300
From: Dan Serban <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question on Lazy IO
Message-ID:
        <cahapvsfvshec3e38yjwsvpbohwnalpfjvkmozkg_7e0vce4...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

I just realized I misread your question in a hurry and gave an
irrelevant answer.
Sorry about that.


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

Message: 6
Date: Thu, 24 Jul 2014 10:53:05 +0300
From: Santtu Keskinen <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question on Lazy IO
Message-ID:
        <cakmxte0ysb1aq-ykdiopqmlw5dtmnvpnc4mgmasn7wbw4+q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Chul-Woong,

Deepseq package can be used to make sure a list is actually fully
constructed before it's used.

import System.IO
import Control.DeepSeq
main :: IO ()
main = do
    s <- getContents
    s `deepseq` hClose stdin
    putStrLn "ECHO result"
    putStr s

Cheers


2014-07-24 9:07 GMT+03:00 ??? <[email protected]>:

> Hi, all.
>
> Haskell's lazy IO causes below program to
> write back "ECHO result" to the user
> even if he doesn't give any input to the program.
>
> test1 :: IO ()
> test1 = do
>   l <- fmap lines getContents
>   putStrLn "ECHO result"
>   putStr $ unlines l
>
> If the client logic, that is the part for feeding data to this program
> and wait for the response, expect the server logic to respond
> only after all the client's request data are feed to the server logic,
> the behaviour could be problematic.
>
> I'm now writing simple web server, as you might guess, and
> my web server responds "HTTP/1.1" before any client's request
> are given. I'm using hGetContents and web server's logic is
> basically same with above code skeleton.
>
> How can I tell the program to respond data only after all the
> requests are feed? Any directions are welcomed.
> Thanks.
>
> Chul-Woong
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140724/4cd3b1b3/attachment.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 73, Issue 18
*****************************************

Reply via email to