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:  reactiva-banana : how to implement a certain type of
      throttling (Heinrich Apfelmus)
   2.  Looking for the paper that defines Arrows. (Michael Litchard)
   3. Re:  Looking for the paper that defines Arrows. (Rustom Mody)
   4.  histogram over large data (Ian Knopke)
   5.  GHC7.4.1 -> LLVM ->W64 (Alexander.Vladislav.Popov )
   6. Re:  histogram over large data (Stephen Tetley)
   7.  attoparsec and EOF (Arthur Clune)
   8. Re:  reactiva-banana : how to implement a certain type of
      throttling (Miguel Negrao)


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

Message: 1
Date: Mon, 04 Jun 2012 17:11:56 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: Re: [Haskell-beginners] reactiva-banana : how to implement a
        certain type of throttling
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

Miguel Negrao wrote:
> Hi list,
> 
> I would like to implement a certain type of throttling of events in
> reactive-banana. It should work such that an event is not let through
> if arrives at less then delta seconds from the last event that passed
> through. If it is not let through then it is stored and is fired after
> delta seconds from the last fired event.
> 
> Below is a program that implements this for lists of time stamped
> numbers. Would it be possible to translate this to reactive-banana ?
> 
> Also, in reactive-banana how do I fire an event x seconds after some
> other event comes in. The way I would do it in scala?s reactive-web is
> to start a timer that fires x seconds after it is started when an
> event comes in using dynamic event switching . It seems to me this
> would not be possible in reactive-banana because starting a timer
> is an IO operation, so I assume it can?t be done inside the
> event/behavior logic, right ?

Miguel, could you repost this question on Stackoverflow, so I can answer 
it there? This way, questions about reactive-banana are easier to find 
later on.

http://stackoverflow.com/questions/ask?tags=reactive-programming+haskell+frp


As for the answer, it is possible to implement the functionality you 
desire in reactive-banana, though it is a little involved.

Basically, you have use an external framework like wxHaskell to create a 
timer, which you can then use to schedule events. The Wave.hs example 
from the examples pages demonstrates how to do that.

Put differently, I have opted to not include time in the reactive-banana 
library itself. The reason is simply that different external framework 
have timers of different resolution or quality, there is no one-size 
that fits it all. I do intend to add common helper functions that deal 
with time and timers to the library itself, but I still need to find a 
good way to make it generic over different timers and figure out which 
guarantees I can provide.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com





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

Message: 2
Date: Mon, 4 Jun 2012 16:32:15 -0700
From: Michael Litchard <[email protected]>
Subject: [Haskell-beginners] Looking for the paper that defines
        Arrows.
To: [email protected]
Message-ID:
        <caezekyrm79fwnukttohmfwxtpebt1o6rnusg9i+sw+jqsh2...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I'm looking for this. Is it necessary to pay someone for the privilege
(the only option I've discovered) ?

John Hughes, Generalising Monads to Arrows, in Science of Computer
Programming 37, pp67-111, May 2000



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

Message: 3
Date: Tue, 5 Jun 2012 08:03:05 +0530
From: Rustom Mody <[email protected]>
Subject: Re: [Haskell-beginners] Looking for the paper that defines
        Arrows.
To: Michael Litchard <[email protected]>
Cc: [email protected]
Message-ID:
        <CAJ+Teoc==y_edc7szvhkr9sge9redja5grneb+mmxdv3yw9...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Tue, Jun 5, 2012 at 5:02 AM, Michael Litchard <[email protected]>wrote:

> I'm looking for this. Is it necessary to pay someone for the privilege
> (the only option I've discovered) ?
>
> John Hughes, Generalising Monads to Arrows, in Science of Computer
> Programming 37, pp67-111, May 2000
>

The first hit by google is
http://www.ittc.ku.edu/Projects/SLDG/filing_cabinet/Hughes_Generalizing_Monads_to_Arrows.pdf

Something else with a similar title you are looking for??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120605/9380d21f/attachment-0001.htm>

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

Message: 4
Date: Tue, 5 Jun 2012 05:11:27 +0100
From: Ian Knopke <[email protected]>
Subject: [Haskell-beginners] histogram over large data
To: [email protected]
Message-ID:
        <cac+f4wmwewbn4bzphxudfaw-fyynuounpnjlqus_suuszkd...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I'd like to build a histogram, or even just a frequency count of some
categorical data from a large database. In a language such as perl I'd
do something like this:

my %freq; # hash
while (my $item = get_next_from_db()){
   $freq{$item}++;
}

and then sum the hash values and divide the value of each key by the
sum to get the histogram.

Is there an easy way to do the same thing in Haskell? It looked like
an easy task but I seem to be having a lot of trouble getting this to
work properly, as it doesn't seem to be behaving very lazily. I'm
guessing I should be doing something with the State monad, but I'm not
very good at using that yet.

Ian



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

Message: 5
Date: Tue, 5 Jun 2012 12:49:08 +0600
From: "Alexander.Vladislav.Popov "
        <[email protected]>
Subject: [Haskell-beginners] GHC7.4.1 -> LLVM ->W64
To: beginners <[email protected]>
Message-ID:
        <calpbq9y2w_ocmgotv4ecmrzs39pysgxuebupa-0zhyfcnkb...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Haskellers,

I want to build 64-bit Windows application.
Will 64-bit mingw and compilation via LLVM help me?
Who will shed light on it and lead me through darkened forest of my search?

Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120605/5159c2d1/attachment-0001.htm>

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

Message: 6
Date: Tue, 5 Jun 2012 07:54:13 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] histogram over large data
To: Ian Knopke <[email protected]>
Cc: [email protected]
Message-ID:
        <CAB2TPRC08h1OK8PVvF1Um_Fu=asroofg88d2vidb8-mgaue...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

It's likely the while loop can be replaced with a fold which has a Map
(or IntMap if the key is an Int) as the accumulator. For a large Map
you will need to pay attention to inserting elements strictly...

The more complicated bit is without any extra knowledge about the
implementation of the "database" `get_next_from_db()` is currently
magic.



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

Message: 7
Date: Tue, 5 Jun 2012 10:56:50 +0100
From: Arthur Clune <[email protected]>
Subject: [Haskell-beginners] attoparsec and EOF
To: [email protected]
Message-ID:
        <CAAa4kjw1PZm9PMhYR+mwaDv7gc=W8bKYTtg_1SQ=zqbxtpm...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I'm writing a simple attoparsec parser, which works fine except for
handling end of file:

value :: Parser T.Text
value = takeWhile1 (/= ' ')

accessLogLine::Parser AccessLogLine
accessLogLine = do
    lts        <- number
    lelapsed   <- skipSpace *> number
    lclientIP  <- space *> value
    -- [... more like this ...]
    lhierarchy <- space *> value
    lmimeType  <- space *> takeWhile1 (not . isEndOfLine) <* endOfLine
    return $ AccessLogLine lts lelapsed lclientIP laction lsize
lmethod lurl lident lhierarchy lmimeType

accessLogParser::Parser [AccessLogLine]
accessLogParser = do
    result <- many accessLogLine
    return result

main = do
    contents <- (S.readFile "/home/arthur/Work/data/sample_acccess_log")
    print (A.maybeResult $ (A.parse accessLogParser $ decodeUtf8 contents))

This all works, but I need to cover the case where the final line in
the file does not end with '\n' and I can't get that to work

I found 
http://stackoverflow.com/questions/2988988/problem-with-incomplete-input-when-using-attoparsec,
which hints at what my problem is, but I can't see how to apply that
here.

Grateful for some hints.

Arthur

--
Arthur Clune [email protected]



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

Message: 8
Date: Tue, 5 Jun 2012 10:58:34 +0100
From: Miguel Negrao <[email protected]>
Subject: Re: [Haskell-beginners] reactiva-banana : how to implement a
        certain type of throttling
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252

A 04/06/2012, ?s 16:11, Heinrich Apfelmus escreveu:

> Miguel, could you repost this question on Stackoverflow, so I can answer it 
> there? This way, questions about reactive-banana are easier to find later on.
> 
> http://stackoverflow.com/questions/ask?tags=reactive-programming+haskell+frp

I?ve reposted the question here: 
http://stackoverflow.com/questions/10888826/reactive-banana-throttling-events

> As for the answer, it is possible to implement the functionality you desire 
> in reactive-banana, though it is a little involved.
> 
> Basically, you have use an external framework like wxHaskell to create a 
> timer, which you can then use to schedule events. The Wave.hs example from 
> the examples pages demonstrates how to do that.
> 
> Put differently, I have opted to not include time in the reactive-banana 
> library itself. The reason is simply that different external framework have 
> timers of different resolution or quality, there is no one-size that fits it 
> all. I do intend to add common helper functions that deal with time and 
> timers to the library itself, but I still need to find a good way to make it 
> generic over different timers and figure out which guarantees I can provide.

Ok, looking at Wave.hs I can see what I need to do to be able to delay an event 
by a certain amount of seconds. The scheduleQueue function there doesn?t 
exactly do what I need it to do, because it schedules relative to the last 
scheduled event. Essentially I would need to alter it such that the scheduling 
is done in absolute terms, so If I ask something to happen 5 seconds from now 
it should really happen 5 seconds from now instead of 5 seconds from the last 
event in queue. One way to do it would be to keep the scheduled times in UTC or 
some other time format and every time an event comes into the queue stop the 
timer, sort the event queue by the absolute times, check how long is it till 
the next event and set the timer delay to be that amount of time, then keep 
repeating the procedure. It would indeed be nice to have something like this 
already available in reactive-banana-wx, or in some timer type independent way 
in the library itself.

Two practical question:
1) How do I filter the slider events (from event0 mySlider command) to get only 
one event instead of 3 every time I move the slider ?
2) What is the best way to set some wx property based on the current value of 
some behavior but only when some event happens ? I?m doing like this now:
reactimate $ apply ((\x->(\y->set slider2 [selection := x])) <$> 
slider1SelectionBehavior) slider1Event

best,
Miguel






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

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


End of Beginners Digest, Vol 48, Issue 3
****************************************

Reply via email to