InquiryLabs

Politics, Programming and Possibilities

Archive for May, 2009

Purposes of Mind

Your mind has four purposes: to make you like the world, and to make the world like you.

Posted via email from Duane’s Quick Posts

  • 2 Comments
  • Filed under: Uncategorized
  • Second Order Abbreviations

    I was reading the following synopsis of a science article today:

    Integrative FGFR1 Signaling (INFS), a new mechanism that plays a central role in adult brain stem cell development and prompts brain stem cells to differentiate into neurons, has been identified by University at Buffalo researchers.

    There seems to be some kind of language bottleneck going on here.  Second-order abbreviations (the “F” in INFS stands for “FGR1″)?  What is the world coming to?  :)

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Powell: “Let’s be more inclusive.”
    Limbaugh: “Powell should get out.”
    Cheney: “I’d pick Limbaugh over Powell.”
    … so they all rolled over and one fell out …
    Article at the NY Times.

    Posted via email from Duane’s Quick Posts

  • 0 Comments
  • Filed under: Uncategorized
  • Visualizing Typed Functions

    As I’ve worked in Haskell over the past several months, I’ve noticed that my mind has kind of implicitly modeled functional programming as a visual/mechanical representation of concepts.  I’d like to make the ideas more explicit, however, so I’m writing this post and cooking up some graphics.  I wonder if others have similar “internal representations” of functions, and if perhaps others might suggest improvements over my model.

    The basic idea is that a function is a semi-circle with inputs on one side (left) and the output at the right.  Colors represent types.  Here is a function that takes one input and produces one output (of the same type):
    Haskell would type this as “a -> a”.  Next, we have a function that takes one type and returns a different type… e.g. a hashing function might take a string and return an integer:
    (Please ignore the vertical stripe, it’s an artifact of my poor Inkscape skills).  We can also create functions with more than one input, of course, so here is a binary function.  It might be the ‘+’ operator, or some other binary operator, e.g. “a -> a -> a”:
    Haskell and many other languages also have the concept of higher-order functions, i.e. functions that take functions as inputs.  Here is a function that takes a binary function as input, along with another input, to produce an output of the same type:
    There exist polymorphic types in many languages as well.  In Haskell, for example, the list is a polymorphic type–it is a linked list of any type you want.  I imagine these polymorphic types as “banded colors” so that the bands contain another type (color).  Here is what the “head” function might look like (”head” returns the first element in a list):
    Finally, here is a composite of all of the above visualizations.  The “map” function in Haskell is a function that takes a function and a list, and applies that function to each element in the list, returning a new list with the “mapped” elements:
    The type signature for the “map” function in Haskell is “(a -> b) -> [a] -> [b]“.
    With these functions visualized, one could make a kind of “drag and drop” interface for Haskell programming, although that isn’t really my intention.  I admit this is a little convoluted even for the purpose of visualization, but at least it’s a starting place.  Does anyone know of another system or better representation?

    Posted via email from Duane’s Quick Posts

  • 3 Comments
  • Filed under: Uncategorized
  • Silkworm Game written in Haskell

    The semester is over, my final project was a success (at least in that I passed the class) and it’s time now to release the game I made for Graphics 455: Silkworm!

    This is my first full application in Haskell.  The process has been an enlarging experience–I’ve come to really enjoy the mental work that goes into thinking about a program in a functional way.  I highly recommend the challenge to other software engineers.
    Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT).
    It’s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms.  The source code is here and below are some screenshots:

    See and download the full gallery on posterous

    Posted via email from Duane’s Quick Posts

  • 8 Comments
  • Filed under: Uncategorized