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:  Recursive macros in hsc2hs (Magnus Therning)
   2.  Re: Recursive macros in hsc2hs (Maur??cio)
   3.  Handling cpp and hsc2hs with Distribution.Simple (Maur??cio)
   4. Re:  type class question from MReader #8 (Brent Yorgey)
   5.  Problems with Internal.ByteString (Pauline Gom?r)
   6.  Talking betwean the parsers. (Maciej Piechotka)
   7.  Parallelizing array-based functions (Jon Harrop)
   8.  Re: Talking betwean the parsers. (Maciej Piechotka)
   9.  Re: Parallelizing array-based functions (Ahn, Ki Yung)
  10. Re:  Talking betwean the parsers. (Felipe Lessa)


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

Message: 1
Date: Wed, 15 Jul 2009 14:15:24 +0100
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] Recursive macros in hsc2hs
To: "Brandon S. Allbery KF8NH" <[email protected]>
Cc: Maur??cio <[email protected]>,        [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Wed, Jul 15, 2009 at 5:21 AM, Brandon S. Allbery
KF8NH<[email protected]> wrote:
> On Jul 14, 2009, at 22:51 , Maurí cio wrote:
>>
>> I'm trying to define a macro inside a template that generates
>> an existing macro:
>
>
> Won't fly; cpp doesn't scan its own output recursively, so if you generate a
> #define in a macro it will appear in the output unexpanded.  AFAIK cpphs is
> no different.

Maybe it's time for someone to write m4hs? ;-)

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


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

Message: 2
Date: Wed, 15 Jul 2009 10:37:15 -0300
From: Maur??cio <[email protected]>
Subject: [Haskell-beginners] Re: Recursive macros in hsc2hs
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

>> I'm trying to define a macro inside a template that generates
>> an existing macro:

> Won't fly; cpp doesn't scan its own output recursively, so if you 
> generate a #define in a macro it will appear in the output unexpanded.  

But isn't this also scanned by hsc2hs? After all, #def
(not #define) is not a cpp macro, but an instruction for
hsc2hs to insert code in a header file. In hsc2hs, a
construct like:

#test

is actually handled by a function definition with name
hsc_test, which outputs an expansion. I can't find, however,
something like hsc_def that I could call from my function.

If I could get my code to be first processed by cpp and
only then by hsc2hs, I think the problem would be solved.
Is it possible to do that?

Maurício



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

Message: 3
Date: Wed, 15 Jul 2009 14:17:06 -0300
From: Maur??cio <[email protected]>
Subject: [Haskell-beginners] Handling cpp and hsc2hs with
        Distribution.Simple
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Cabal package manual says those tools are handled
automatically using extensions in file names, i.e.,
'.hsc' for hsc2hs and '.cpphs' for haskell cpp.

What should I do if I want both, i.e., I would
like my file to be processed first by cpp and then
by hsc2hs?

Thanks,
Maurício



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

Message: 4
Date: Fri, 17 Jul 2009 10:19:24 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] type class question from MReader #8
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1

On Tue, Jul 14, 2009 at 10:05:03AM -0400, MH wrote:
> Could you please elaborate on how does the constraint (ListConcat xs
> ys zs) makes the instance ListConcat (x ::: xs) ys (x ::: zs)
> recursive.

> >> instance (ListConcat xs ys zs)
> >>             => ListConcat (x ::: xs) ys (x ::: zs) where listConcat = _|_

This says that '(x ::: xs) ys (x ::: zs)' is an instance of ListConcat
*if* 'xs ys zs' is.  So you can think of the 'ListConcat xs ys zs'
constraint as a recursive call made by 'ListConcat (x ::: xs) ys (x
::: zs)'.  As a Haskell function we might write it something like
this:

  isListConcatInstance (x ::: xs) ys (z ::: zs) = x == z && 
isListConcatInstance xs ys zs

Does that help?

-Brent


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

Message: 5
Date: Fri, 17 Jul 2009 22:57:33 +0200
From: Pauline Gom?r <[email protected]>
Subject: [Haskell-beginners] Problems with Internal.ByteString
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

Hello,

I'm trying to upgrade a library from 6.6 to 6.10, but has run into a problem
where a Internal.ByteString is returned instead of a normal ByteString. The
library uses bRead in BEncode library, but that function's input type has
changed from ByteString to Internal.ByteString. I think the cause of the
problem is the functions in ByteString that uses functions in
ByteString.Internal.

Data.BEncode.bRead                         uses Data.BEncode.Lexer.lexer
Data.BEncode.Lexer.lexer                  uses
Data.ByteString.Lazy.Char8.toChunks
Data.ByteString.Lazy.Char8.toChunks uses
Data.ByteString.Lazy.Internal.foldrChunk

foldrChunk :: (Internal.ByteString -> a -> a) -> Internal.ByteString -> a

Is there any way to avoid getting a Internal.ByteString or convert it to a
normal ByteString?

Pauline
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090717/821615ba/attachment-0001.html

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

Message: 6
Date: Sat, 18 Jul 2009 00:40:15 +0200
From: Maciej Piechotka <[email protected]>
Subject: [Haskell-beginners] Talking betwean the parsers.
To: [email protected]
Message-ID: <1247870415.2912.108.ca...@notebook>
Content-Type: text/plain; charset="us-ascii"

I have a data structure of 
data Monad m => NntpConnection m = NntpConnection {
        input :: ByteString,
        output :: ByteString -> m ()
    }

I'd like to create echo structure such that the goes to output is going
to (lazy) input. For sure it is possible to use network and IO monad -
is is possible to do it purely?

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090717/283ab0db/attachment-0001.bin

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

Message: 7
Date: Sat, 18 Jul 2009 01:06:38 +0100
From: Jon Harrop <[email protected]>
Subject: [Haskell-beginners] Parallelizing array-based functions
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="us-ascii"


If you have a function that mutates the elements of an array in-place and 
leverages parallelism by recursively subdividing the problem and mutating 
parts of the array separately, can this be expressed in Haskell?

In-place quicksort and many of the numerical methods from linear algebra fall 
into this category.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


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

Message: 8
Date: Sat, 18 Jul 2009 01:05:15 +0200
From: Maciej Piechotka <[email protected]>
Subject: [Haskell-beginners] Re: Talking betwean the parsers.
To: [email protected]
Message-ID: <1247871915.2912.111.ca...@notebook>
Content-Type: text/plain; charset="us-ascii"

On Sat, 2009-07-18 at 00:40 +0200, Maciej Piechotka wrote:
> I have a data structure of 
> data Monad m => NntpConnection m = NntpConnection {
>       input :: ByteString,
>       output :: ByteString -> m ()
>     }
> 
> I'd like to create echo structure such that the goes to output is going
> to (lazy) input. For sure it is possible to use network and IO monad -
> is is possible to do it purely?
> 
> Regards

I come up to with:

createEcho :: IO (NntpConnection IO)
createEcho = do (r, w) <- runKleisli (Kleisli fdToHandle ***
                                      Kleisli fdToHandle) =<< createPipe
                hSetBuffering r LineBuffering
                hSetBuffering w LineBuffering
                c <- hGetContents r
                return $ NntpConnection c $ hPut w

Which have advantage of not involving network stack but is
POSIX-specific.

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090717/f6055905/attachment-0001.bin

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

Message: 9
Date: Fri, 17 Jul 2009 16:25:58 -0700
From: "Ahn, Ki Yung" <[email protected]>
Subject: [Haskell-beginners] Re: Parallelizing array-based functions
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Jon Harrop wrote:
> If you have a function that mutates the elements of an array in-place and 
> leverages parallelism by recursively subdividing the problem and mutating 
> parts of the array separately, can this be expressed in Haskell?
> 
> In-place quicksort and many of the numerical methods from linear algebra fall 
> into this category.

Most relevant work I know of is DPH:

http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell
http://www.cse.unsw.edu.au/~chak/project/dph/

but this isn't exactly about in-place algorithms.  Although in theory it 
may be possible to optimized as in-place when compiling it down in 
certain situations, I don't think it would enforce that in general.

However, when working with monadic code and mutable arrays one can 
always fork Haskell threads with forkIO or using other similar 
libraries.  This can of course do in-place quicksort kind of things in 
parallel, but I don't think what you've expected is this.

Is there a nice work going on in OCaml or F#?



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

Message: 10
Date: Fri, 17 Jul 2009 20:47:31 -0300
From: Felipe Lessa <[email protected]>
Subject: Re: [Haskell-beginners] Talking betwean the parsers.
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Sat, Jul 18, 2009 at 12:40:15AM +0200, Maciej Piechotka wrote:
> I have a data structure of
> data Monad m => NntpConnection m = NntpConnection {
>       input :: ByteString,
>       output :: ByteString -> m ()
>     }
>
> I'd like to create echo structure such that the goes to output is going
> to (lazy) input. For sure it is possible to use network and IO monad -
> is is possible to do it purely?

In words, not code: you may create a Chan of strict ByteStrings.
On the output side you just append all the chunks of the lazy
ByteString to the Chan, or you may copy the lazy ByteString in
one chunk of strict ByteString.  On the input side you
"getContents" and "fromChunks".  Should work, I guess.

--
Felipe.


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

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


End of Beginners Digest, Vol 13, Issue 9
****************************************

Reply via email to