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.

? is not Maybe

[identity profile] davidsarah.livejournal.com 2009-08-08 08:43 pm (UTC)(link)
"Maybe is the same thing as Kleene ? (the "zero or one" operator in regular expressions)."

Nope. The types are significantly different. Kleene ? operates on sets of sequences; Maybe is a constructor for a discriminated union:

extension(T?) = extension(T) union {[]}.
extension(Maybe T) = {Some t | t in extension(T)} union {Nothing}.

This is not just nitpicking, honestly :-)

(You seem to have typeclasses right.)