|
 |
>> integer * string
>> which seems a rather perverse choice.
>
> Cartesian product of integers and strings. I'm not sure what a "sum
> type" would be.
Either Int String
is a sum type. The set of possible values is the *sum of* the set of
possible Int values and the set of possible String values.
Whereas... well, you understand what a Cartesian product is already, right?
Haskell's "algebraic data types" are sum types of product types. (The
sum may contain only one summand, but a sum none the less. Actually, if
you enable the EmptyDataDecls extension, zero summands are permissible...)
>> instead of "(True, 5)"? It would be clearer...)
>
> Wait till you get to python, where the tuple constructor is actually the
> comma, the parens are optional, and you try to figure out how to write a
> one-element tuple literal, or the empty tuple.
Oh, the *type constructor* for a 2-tuple is "(,)", and for a 3-tuple
it's "(,,)".
So if you want to be 73% anal, you can write "(,) String Integer"
instead of "(String,Integer)". :-}
Off the top of my head, I don't *believe* this works with value
constructors... No, wait. I'm wrong; it does work.
(,,) :: a -> b -> c -> (a,b,c)
This means we can write
zip = zipWith (,)
Eat THAT and smoke it! o_O
(Similarly, "[Char]" can also be written "[] Char".)
>> Haskell makes the rather illogical choice of using "--" as the start
>> marker for a comment.
>
> Common in a lot of other languages like SQL and Ada. FWIW.
I know Eiffel uses it. But then, Eiffel is weird.
>> Ocaml uses the even stranger choice of "(* ... *)".
>
> Which is Pascal for comments, if your keyboard (punched cards) don't
> have curly braces. FWIW.
...more useless information to add to my collection! o_O
Then again, in Pascal "(*)" is not a meaningful thing to write in the
first place. ;-)
PS. I'm loving the way Haskell uses curly brackets for explicit
grouping, AND ALSO for named-field syntax. Way to use the exact same
symbol for two unrelated things that you might want to do AT THE SAME TIME!
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |