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:  Question about Regular expression pattern    consuming.
      (S. H. Aegis)
   2.  listenOn specific IP (vold)
   3. Re:  listenOn specific IP (vold)
   4.  Viewing Template Haskell output? (Lee Short)
   5. Re:  Viewing Template Haskell output? (14875)


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

Message: 1
Date: Mon, 29 Jul 2013 22:15:35 +0900
From: "S. H. Aegis" <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question about Regular expression
        pattern consuming.
Message-ID:
        <cajp-nqwpx1czscmogtaqa4auhvfdcxmu+kncpn1bmyonngb...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Wow! It's cool.

One more question, please...
In the DATA file, there is several 20[0-9]{13}AH201 strings.
How can I treat all of each pattern?
Thank you.

Sincirely, S. Chang.


2013/7/29 Julian Arni <[email protected]>

> splitRegex treats the regex as a delimiter, and does it fact "swallow" the
> match. Use matchRegexAll instead - e.g.:
>
> 1 import Text.Regex
>   2 import Control.Applicative
>   3
>   4 main :: IO()
>   5 main = do
>   6     myIn <- readFile "Data.dat"
>   7     case (intoEachPt myIn) of
>   8         Nothing -> print "No match"
>   9         Just (a, b, c, d) -> do print a
>  10                                 print b
>  11                                 print c
>  12
>  13 intoEachPt :: String -> Maybe (String, String, String, [String])
>  14 intoEachPt = matchRegexAll (mkRegex "20[0-9]{13}AH021")
>
>
> On Sun, Jul 28, 2013 at 5:35 AM, S. H. Aegis <[email protected]> wrote:
>
>> Hi.
>> I'm newbie to Haskell.
>> I want to get date, it's type is [[String]].
>> The problem is that "the string that is used in regular expression
>> pattern" is consumed. ie, disappear.
>> Here is my code.
>>
>> ------------------------------------------------------------
>> import Text.Regex
>> import Control.Applicative
>>
>> main :: IO()
>> main = do
>>     myIn <- readFile "Data.dat"
>>     print $ lines <$> intoEachPt myIn
>>
>> intoEachPt :: String -> [String]
>> intoEachPt = splitRegex (mkRegex "20[0-9]{13}AH021")
>> -----------------------------------------------------------
>>
>> How can I fix this?
>>
>>
>> Data:
>> ....there is many DIGIT.....201306000300001AH02112361640
>> 9.......
>>
>> Output:
>> [[....there is many DIGIT..."],["12361640             9......]....]
>>
>> I hope:
>> [[....there is many DIGIT..."],["201306000300001AH02112361640
>> 9......]....]
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
Sok Ha, CHANG
Dr. Chang's Clinic. #203. 503-23. AmSa-Dong, GangDong-Gu, Seoul.
Tel: +82-2-442-7585
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130729/d44f1086/attachment-0001.html>

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

Message: 2
Date: Tue, 30 Jul 2013 09:29:24 +0000 (UTC)
From: vold <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] listenOn specific IP
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

I'm trying to write a simple server with network. listenOnSource takes a
socket number, but tries to bind to every available IP, which isn't what I
need. How do I tell it to bind to a specific address?




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

Message: 3
Date: Tue, 30 Jul 2013 13:49:15 +0000 (UTC)
From: vold <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] listenOn specific IP
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

vold <voldermort <at> hotmail.com> writes:

> I'm trying to write a simple server with network. listenOn takes a
> socket number, but tries to bind to every available IP, which isn't what I
> need. How do I tell it to bind to a specific address?

I did this eventually by writing my own copy of the listenOn function

listenOn' host (PortNumber port) = do
    proto <- getProtocolNumber "tcp"
    bracketOnError
        (socket AF_INET Stream proto)
        (sClose)
        (\sock -> do
            setSocketOption sock ReuseAddr 1
            bindSocket sock (SockAddrInet port host)
            listen sock maxListenQueue
            return sock
        )

It feels very hacky though.




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

Message: 4
Date: Tue, 30 Jul 2013 09:30:00 -0700
From: Lee Short <[email protected]>
To: <[email protected]>
Subject: [Haskell-beginners] Viewing Template Haskell output?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

I'm working with some Yesod code, and it's complaining about some 
missing function definitions.  I'd really like to see the code that 
Template Haskell is outputting -- this is hard to debug otherwise.  The 
--ddump-splices output is managable at this early stage, but I can't 
imagine using it once I add more functionality and the code grows.  Is 
there way to get the template haskell output code?




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

Message: 5
Date: Wed, 31 Jul 2013 01:09:59 +0800
From: 14875 <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: [Haskell-beginners] Viewing Template Haskell output?
Message-ID:
        <CABCDVh0sh2g=zt6rkjme_vg5nepg2kx2mxmbty_m56aqfa4...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I think your looking for this:
http://hackage.haskell.org/packages/archive/template-haskell/latest/doc/html/Language-Haskell-TH-Ppr.html
use pprint or ppr to print template haskell generated code although it's a
bit ugly
but I prefer avoiding template haskell personaly such as happstack

2013/7/31 Lee Short <[email protected]>

> I'm working with some Yesod code, and it's complaining about some missing
> function definitions.  I'd really like to see the code that Template
> Haskell is outputting -- this is hard to debug otherwise.  The
> --ddump-splices output is managable at this early stage, but I can't
> imagine using it once I add more functionality and the code grows.  Is
> there way to get the template haskell output code?
>
>
> ______________________________**_________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130731/4099c745/attachment-0001.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 61, Issue 35
*****************************************

Reply via email to