maradydd: (Default)
maradydd ([personal profile] maradydd) wrote2009-07-30 11:07 pm

Things I figured out about Haskell today

  • Maybe is the same thing as Kleene ? (the "zero or one" operator in regular expressions).
  • A typeclass is the same thing as an STL concept, but a typeclass actually means it.
  • instance means "We're going to make this data type an instance of this typeclass, and here's how."
Now if I can just get my head around monads, I'm set.

[identity profile] neoliminal.livejournal.com 2009-07-30 10:34 pm (UTC)(link)
Haskell scares me. In the same way that someone showed me you could make the number "1" into a function in Python. Although it's very entertaining that you can define a variable as infinity and only use the parts of infinity that you need at a given time.
michiexile: (Default)

[personal profile] michiexile 2009-07-31 06:19 am (UTC)(link)
Oh, but making numbers, or constants in general, into functions is very much in line with the underlying mathematics of functional programming.

An element of an object in a nice category - say, for instance a data type in an appropriate category of data types and computable functions - is a computable function from the terminal object (to which there is one unique map from every other object) to your object.

So, in Haskell terms, an element is just a 0-ary function
1 :: () -> Int
and then the compiler is gracious enough to give us syntax sugar for 0-ary functions.