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:  Prolog (alexraasch)
   2.  dynamic set of objects in netwire (Nathan H?sken)
   3. Re:  dynamic set of objects in netwire (Ertugrul S?ylemez)


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

Message: 1
Date: Wed, 07 Nov 2012 14:48:21 +0100
From: alexraasch <[email protected]>
Subject: Re: [Haskell-beginners] Prolog
To: <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

Also check out Curry, it's (almost) a superset of Haskell with free 
variables like in Prolog. Looks very elegant.

Am 2012-10-28 18:12, schrieb Karl Voelker:
> On Sat, Oct 27, 2012 at 11:27 PM, Christopher Howard
> <[email protected]> wrote:
>> Hi. I still have a lot to learn in Haskell (who doesn't?) but I was
>> thinking about learning Prolog on the side. I was wondering what you
>> thought about the language.
>
> Prolog can be fun. I wouldn't let its impurity deter you from
> experimenting with it. You might also be interested in:
>
> http://en.wikipedia.org/wiki/Mercury_(programming_language)
> http://en.wikipedia.org/wiki/Datalog
>
> -Karl
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners




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

Message: 2
Date: Wed, 07 Nov 2012 15:47:30 +0100
From: Nathan H?sken <[email protected]>
Subject: [Haskell-beginners] dynamic set of objects in netwire
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hey,

I need (in netwire) a way to handle a dynamic set of objects. Therefor I
need a way of growing and shrinking the set. Since I have little
experience with Haskell and FRP, I would appreciate some input.

Shrinking is not problem, as I can just remove wires that inhibit. But
how to let the set grow?

So far, my main loop would look like this:
I have input data
data Input = UpdatePhysic | KeyDown Int ...

and the main Wire which creates objects on certain inputs and updates
the physics when UpdatePhysics is send:

    mainWire :: WireP Input
    mainWire = proc input -> do
       userControlledObject <- userControlledObjectWire -< input

       if input == UpdatePhysics then do
         rec
           letCollData = ...
           physicsObjects <- physicsObjectsWire -< collData
       else
          empty -<


My idea for the dynamics set wire is this:

    data Subwire e m a b = forall a'. Subwire (a -> a') (Wire e m a' b)
    dynamicSet :: (Monad m) => (c -> Subwire e m a b) -> Wire e m
(Either a c) b

The Idea is that the dynamicSet in every invocation either creates wires
or steps them:

    mainWire :: WireP Input
    mainWire = proc input -> do
      userControlledObject <- userControlledObjectWire -< input
      rec
        let collisionData = ...
        objects <- dynamicSet -< if input == UpdatePhysics then Left
collisionData else Right input

So far so good, what bothers me is, that when I have several dynamicSets
(different kind of objects) I have to make several if input == ... then
... else ... constructs, which feels repeative.

I would welcome some input on how to structure the main loop and/or
dynamic set...

Regards,
Nathan



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

Message: 3
Date: Wed, 7 Nov 2012 19:46:14 +0100
From: Ertugrul S?ylemez <[email protected]>
Subject: Re: [Haskell-beginners] dynamic set of objects in netwire
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Nathan H?sken <[email protected]> wrote:

> I need (in netwire) a way to handle a dynamic set of objects.
> Therefor I need a way of growing and shrinking the set. Since I have
> little experience with Haskell and FRP, I would appreciate some input.
>
> Shrinking is not problem, as I can just remove wires that inhibit. But
> how to let the set grow?

Originally the 4.0.0 release should include the manager wire, but I have
long tried to come up with an interface that is generic enough to fit in
as many situations as possible.

The most obvious interface is through input.  However, this really only
works when only the user of the manager should be able to add or remove
subwires.  The interface is as simple as something like this:

    data MgrMsg k e m a b =
        Add k (Wire e m a b) |
        Delete k

    managerBasic ::
        (Monad m, Monoid b, Ord k) =>
        Wire e m (a, [MgrMsg k e m a b]) b

For many (if not most) applications the individual subwires should be
allowed to control the current set of subwires as well, which is
possible by adjusting the interface slightly and then using feedback:

    data MgrMsg k e m a b =
        Add k (Wire e m a (b, MgrMsg k e m a b)) |
        Delete k

    managerFeedback ::
        (Monad m, Monoid b, Ord k) =>
        Wire e m (a, [MgrMsg k e m a b]) (b, [MgrMsg k e m a b])

Then you can use feedback:

    loop (managerFeedback . second (delay []))

This interface could fit your needs.  However, in general there may also
be the desire to have control over the current subwire set via the
underlying monad, which is a very intriguing idea, because not only does
that allow more efficiency without feedback, but it also allows the
subwire set to be managed outside of the wire, even from another thread.


> So far, my main loop would look like this:
> I have input data
> data Input = UpdatePhysic | KeyDown Int ...
>
> and the main Wire which creates objects on certain inputs and updates
> the physics when UpdatePhysics is send:

You may be thinking too imperatively and/or too discretely here.  Notice
that FRP is about a continuous model.  On its surface wires should
always look like functions of time and input.  In particular events
should not discretely cut the input-output connection as they would do
in your case:

> The Idea is that the dynamicSet in every invocation either creates
> wires or steps them:
>
> [...]

In other words:  Don't think too much in terms of stepping/invocation.
Actually in a perfect world FRP is so opaque that you totally forget
about the underlying discrete time steps. =)


Greets,
Ertugrul

-- 
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121107/48b8c350/attachment-0001.pgp>

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

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


End of Beginners Digest, Vol 53, Issue 12
*****************************************

Reply via email to