Meeting notes: August 10, 2009 -- FRP, Arrows, Type Classes, and Unit Hacking

24 views
Skip to first unread message

Igal Koshevoy

unread,
Aug 11, 2009, 8:47:56 PM8/11/09
to pdxfunc
We had a great meeting at the Lucky Lab SE event room. This was the longest, most content-filled user group meeting I've been to. Although we had presentations for the two scheduled hours, the final presentation turned into an interactive hackathon that lasted till the Lab closed for the night.

DISCLAIMER: I try to use quotes and links as much as possible because my understanding of this subject matter is limited. Please post corrections.

1. Julian Blake Kongslie on Functional Reactive Programming (FRP) in Haskell
  • FRP resources:
  • On FRP: ~Let's say that I want to write a game and I want to write it in a FP language, but I don't want to use the IO Monad anywhere in my code. So I'm going to write code that's purely declarative that'll describe the game's rules, e.g., this event happens precisely after this event. Something in the background will collect events and fire them off.~
  • On leaks: ~Unfortunately, because the game is lazy, it's not making good use of computational resources and has a "time leak", where it does a bunch of calculation at the point when this is needed. Meanwhile, these can also have "space leaks", where it carries so much state around that it's carrying all the data around all the time. These problems plague "Fran", the simplest and first of these libraries.~
  • Conal Elliot is the expert on FRP, but is rather hard to understand at times.
  • "Fran" is an early and simple, is pure functional. Was abandoned because its types became insane and due to its space and time leaks. Conal Elliot's tutorial on Fran also covers FRP concepts: http://conal.net/fran/tutorial.htm
  • "Yampa" is provides functional reactive programming, but uses arrows in part to eliminate/reduce space and time leaks in libraries like Fran. This project seems to have been abandoned. It includes a good introduction to arrows. Yampa home page: http://haskell.org/yampa/

2. Julian Blake Kongslie on arrows in Haskell
  • Arrow resources:
  • Monads vs. arrows:
    • ~Monads model iterative processes, where the flow of data goes from left to right. Monads describe important things, such as continuation passing -- thus they should be sufficient to describe any Turing complete system. Arrows are an alternative way to describe a computational system. You cannot embed arrows in most monads -- but any arrow can include monads. Rather than left to right, they describe movement on a graph.~
    • ~The 'arr' arrow, the simplest of these, when given a function (e.g., increment by 1), it lifts the function into arrow space -- a pure process. There's a simple way to pipeline, connect two arrows to feed from one into the next as a composition. The arrow composition lets you chain arrows, choose which arrow to feed a value to, choose whether to feed data to an arrow or skip over it, loop through an arrow where its output is connected to its input, etc.~
    • ~The ability to loop requires general recursion, which is not well defined, and thus cannot be embedded in all but the most sophisticated monads. It's about discrete chunks of computation that you're wiring together, like hardware circuit design. If you already have something that already wants to be designed this way, e.g., an MPEG decoder that's already defined by block diagrams, then you'll probably want to use arrows.~
    • ~Arrow notation quickly descends into dot-free notation with many compositions and looping processes that are hard to keep track of. It loses the FP property of making it easy to understand individual parts of the program and reason about their computation, whereas with arrow notation you must understand the whole because it introduces loops and such. Everything happens at the same time, there can be multiple returns, there can be non-deterministic behavior. There's the backwards arrow notation, to evaluate from right to left.  Objections are: ugly syntactic representation and permits the semantic expressions of rats nests that are hard to reason about.~
    • ~Labview uses arrows for building things like rockets, airplanes, and robot controls. It runs very quickly by making good use of arrows.~
    • ~There's been several syntax implementations of arrows in Haskell, modern ones are better but require compiler support to handle the odd syntax, and still need the wacky backwards arrow. Some have tried to make this a preprocessor step, but these haven't been popular.~
    • ~The "Spineless, Tagless G-Machine" avoids using monads.~ {But it doesn't use arrows either?}

3. Jesse Hallett on "$" operator in Haskell
  • ~A common thing I hear from people put off by Haskell is that there are too many weird operators, but once you study them, they begin to make sense. The "$" operator is one of these. The "$" operator exists is because many programmers hate parens. Lisp featured a "$" like operator for alternative representation that became part of Haskell.
  • Usage:
     -- Parens notation
    putStrLn (1 + 2 + 3)
    -- Dollar notation
    putStrLn $ 1 + 2 + 3
    ($) :: (a -> b) -> a -> b
    a $ b = a b
    ($) = id

    -- Parens notation
    a (b (c d))
    -- Dollar notation
    a $ b $ c $ d

4. Jesse Hallett on Type Classes and unit conversion in Haskell
  • How can we perform unit conversions elegantly? For example, perform calculation such as:
    L 3 Feet + L 4 Meters => L 16.119999999999997 Feet
  • Jesse demoed one possible solution, and then some of the faithful stayed for another few hours producing progressively more elegant solutions. Watching the code evolve to incorporate clarifications and refinements was fascinating and helped demonstrate Haskell's expressiveness.
  • Source code for various solutions: http://gist.github.com/160019

LOLs
  • "So if you had a wiggle-wiggle, you'd get a circle?" "No, a diagonal."
  • "Time is a mythical construct, our functions have different effects depending on the state of our universe."
  • "I'm impressed by how you can type with your middle finger sticking out like that."
  • "Infinite recursion. Black hole exception. Halting problem solved."
-igal

Matt Youell

unread,
Aug 12, 2009, 5:19:06 PM8/12/09
to pdxfunc
On Aug 11, 5:47 pm, Igal Koshevoy <i...@pragmaticraft.com> wrote:
> We had a great meeting at the Lucky Lab SE event room. This was the
> longest, most content-filled user group meeting I've been to. Although
> we had presentations for the two scheduled hours, the final presentation
> turned into an interactive hackathon that lasted till the Lab closed for
> the night.

1. Thanks for the detailed notes Igal. I nominate you all-time note-
taker for life. :)

2. I'm completely bummed I missed this one. Everything came together
so late and with no firm presentations planned, and being August, I
figured I was on safe ground missing one... Oops!

3. Apparently Haskell has a little more kick to it than I initially
gave it credit for. I've had to delay my blog post - which bemoans
some of the missed opportunities of types - so I can spelunk the cave
of Haskell and keep more of my foot out of my mouth. If that is
possible.

Can I create a Foot type that will refuse to be contained by Mouth?

--
-/matt/-
http://youell.com/matt

Thomas DuBuisson

unread,
Aug 12, 2009, 5:26:21 PM8/12/09
to pdx...@googlegroups.com
Matt Youell<softb...@gmail.com> wrote:
>
> On Aug 11, 5:47 pm, Igal Koshevoy <i...@pragmaticraft.com> wrote:
>> We had a great meeting at the Lucky Lab SE event room. This was the
>> longest, most content-filled user group meeting I've been to. Although
>> we had presentations for the two scheduled hours, the final presentation
>> turned into an interactive hackathon that lasted till the Lab closed for
>> the night.
>
> 1. Thanks for the detailed notes Igal. I nominate you all-time note-
> taker for life. :)
>
> 2. I'm completely bummed I missed this one. Everything came together
> so late and with no firm presentations planned, and being August, I
> figured I was on safe ground missing one... Oops!

I too thought this would be a safe one to miss (though I have never
attended), damn! Thanks for the notes, I guess I have to go off and
read more about reactive (frp).

> Can I create a Foot type that will refuse to be contained by Mouth?

Unfortunately that isn't possible with the Haskell type system (now
watch Oleg prove me wrong). With some work you could create a Mouth
that would refuse to contain Foot... of coarse that isn't any
different than the English language.

Thomas

Reply all
Reply to author
Forward
0 new messages