Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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: Are Arrows good for simulation purposes (Benjamin Edwards)
2. Point free mystery (martin)
3. Re: Left vs Right (Chadda? Fouch?)
4. Re: Point free mystery (Brandon Allbery)
5. Re: Left vs Right (emacstheviking)
----------------------------------------------------------------------
Message: 1
Date: Wed, 15 Apr 2015 18:13:18 +0000
From: Benjamin Edwards <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Are Arrows good for simulation
purposes
Message-ID:
<can6k4nj8bn0_+bb0s_li1wzgk9lepgpfqscczi2vogmnljn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
It might be worth your while to look at netwire or auto, which both use
arrows to model networks.
Ben
On Tue, 31 Mar 2015 at 06:35 martin <[email protected]> wrote:
> Hello all,
>
> little do I know about arrows, but the "stream processor" metaphor
> suggests, that they can be used to simulate a network
> of things, services or data. Is this correct?
>
> I came across the following thought: When I simulate a billard game with a
> DES, I would compute collisions of balls with
> each other and with the banks, creatign a set of events, of which only the
> earliest will be considered to compute the
> next state. This is pure DES and does not seem to be a good candidate for
> arrows. In this case I'd be more interested in
> composing collision detectors than in stream processing.
>
> OTOH, when I move parcels around and process then in various stages, then
> a "stream processor" would make perfect sense
> to me. In that case, would I abandon the DES paradigm entirely (including
> the notion of an event queue) and just model
> the network and let it run?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/2ecfca51/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 15 Apr 2015 21:31:27 +0200
From: martin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Point free mystery
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Helly all
for ad-hoc benchmarking I wrote
bench x = (timeIt . print) x
Hlint suggested
Found:
bench x = (timeIt . print) x
Why not:
bench = (timeIt . print)
but when I do this, I get
No instance for (Show a0) arising from a use of ?print?
Why is that so?
------------------------------
Message: 3
Date: Wed, 15 Apr 2015 21:39:36 +0200
From: Chadda? Fouch? <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Left vs Right
Message-ID:
<canfjzrabkqzwccdzw83ry8j1n7cdyoygbvsmyphohpqrkwg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
>
> 15 ????. 2015 19:27 "emacstheviking" <[email protected]> ????:
>
> I just love the way Haskell can blow something really simple into
>> something truly mind blowingly obtuse looking at times!
>> It's no wonder Haskell won't be "mainstream" for a while yet, but that's
>> fine, it means the rest of us can charge better rates for now.
>> :)
>>
>>
This is simple. More precisely, it couldn't be otherwise.
data Either l r = Left l | Right r
See how this definition has two type parameters ? The problem was obscured
in the first question by the fact that "replicate 3" can be applied to any
type. But if you take a less polymorphic function like length, it soon
become obvious that this is the way fmap should work :
fmap length (Right "stuff") = length "stuff"
fmap length (Left 5) = length 5 ???? What does that even means ?
Since the type contained by Left and Right are different, you can't in
general apply the same function to both possibilities. Now the right type
is the last one to occur in "Either left right" so it's the one that's
abstracted over in the Functor instance, there is no Functor instance for
Either, the instance is for "Either left" with the left type fixed, fmap
don't touch the left type, so it can't do anything to a "Left x" value.
Semantically, "Either left right" can be seen as a container of one or zero
"right" that contains out-of-band information of type "left" when it's
empty. So when you fmap over it, you only touch the content, not the
out-of-band information.
--
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/c982d96c/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 15 Apr 2015 15:42:37 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Point free mystery
Message-ID:
<cakfcl4xdghbmqtrac_x_h-awhtap2db-jjt4aukgrpo4pvj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Wed, Apr 15, 2015 at 3:31 PM, martin <[email protected]> wrote:
> Hlint suggested
>
> Found:
> bench x = (timeIt . print) x
> Why not:
> bench = (timeIt . print)
>
hlint is kinda dumb sometimes, like any heuristic analyzer. In particular,
it recognizes patterns of code, but knows nothing about types. Or, in this
case, the monomorphism restriction, which is likely messing with the
inferred type (since the inferred type is correct when it has a parameter).
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/a1e34bff/attachment-0001.html>
------------------------------
Message: 5
Date: Thu, 16 Apr 2015 09:41:29 +0100
From: emacstheviking <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Left vs Right
Message-ID:
<caeieuukfav_tht9yzlqxsseal-viwlj_dozmqx-ddrs2puj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
"Semantically, "Either left right" can be seen as a container of one or
zero "right" that contains out-of-band information of type "left" when it's
empty. So when you fmap over it, you only touch the content, not the
out-of-band information."
Yup. Whatever he said. ;) ...that's bordering on monadic comparison
tutorials if you ask me... LOL. A lot of people may not even know what "in
band" and "out-of-band" even means. I grew up with X25, RS232, HDLC etc so
that's ok by me. You have to be very very careful about how you explain
things to people. One of my favourite videos on YouTube is some guy asking
Richard Feynman how magnets work...well, he did ask!
https://www.youtube.com/watch?v=wMFPe-DwULM
On 15 April 2015 at 20:39, Chadda? Fouch? <[email protected]> wrote:
> 15 ????. 2015 19:27 "emacstheviking" <[email protected]> ????:
>>
>> I just love the way Haskell can blow something really simple into
>>> something truly mind blowingly obtuse looking at times!
>>> It's no wonder Haskell won't be "mainstream" for a while yet, but that's
>>> fine, it means the rest of us can charge better rates for now.
>>> :)
>>>
>>>
> This is simple. More precisely, it couldn't be otherwise.
>
> data Either l r = Left l | Right r
>
> See how this definition has two type parameters ? The problem was obscured
> in the first question by the fact that "replicate 3" can be applied to any
> type. But if you take a less polymorphic function like length, it soon
> become obvious that this is the way fmap should work :
>
> fmap length (Right "stuff") = length "stuff"
> fmap length (Left 5) = length 5 ???? What does that even means ?
>
> Since the type contained by Left and Right are different, you can't in
> general apply the same function to both possibilities. Now the right type
> is the last one to occur in "Either left right" so it's the one that's
> abstracted over in the Functor instance, there is no Functor instance for
> Either, the instance is for "Either left" with the left type fixed, fmap
> don't touch the left type, so it can't do anything to a "Left x" value.
>
> Semantically, "Either left right" can be seen as a container of one or
> zero "right" that contains out-of-band information of type "left" when it's
> empty. So when you fmap over it, you only touch the content, not the
> out-of-band information.
>
> --
> Jeda?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150416/98bab247/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 82, Issue 17
*****************************************