Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Languages you hate

Name: Anonymous 2009-02-13 17:51

Fortransexuals

Name: Anonymous 2009-02-17 13:14

>>84
It's a lot like Nullable<T>. It's either a wrapped value, or a

IN-DEPTH EXPALINATION, HOLY SHIT:
1) Haskell doesn't distinguish between heap and stack variables; that's the compiler's job.
2) There's no null in Haskell, because then you would have to check for null values in every goddamn function, which is stupid. Better to have the type system check it at runtime.
3) Haskell datatypes are tagged unions, which means that depending on how you instantiate them they can have different "instance variables" of different types. In the case that a data constructor takes zero arguments, it's effectively an enumerated constant:

    data Bool = True | False
    -- ACTUAL DEFINITION IN THE HASKELL SOURCE CODE

(To fake this in Java, you would have to create a Bool class and then subclass it as True and False.)
4) So long as a datatype's constructor functions are in scope, you automatically get read-only access to the datatype's contents.
5) If the type name itself takes an argument, that type is automatically made into a template. The syntax is the same as function calls.

So now that you know what you're about to look at:
    data Maybe t = Just t | Nothing

Nothing is Haskell-ese for null. Just t is Haskell-ese for "an arbitrary value that isn't null." Because the actual value you want is hidden inside the Just function, any time you're dealing with a value that might be null, it's impossible to do anything with it unless you check whether it's null.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List