[bitc-dev] Opinions wanted: Infix shift operators

wren ng thornton wren at freegeek.org
Mon Aug 9 21:00:00 PDT 2010


Jonathan S. Shapiro wrote:
> BitC is an expression language. All of the statement-like forms are
> expressions. So I mean expression-terminating. You stated elsewhere that
> Haskell doesn't permit expressions as statements. This confuses me, since I
> had thought that (e.g.) the Haskell LET statement was an expression...

Statements in Haskell are top-level things contained in a module 
definition. These include module imports, data, type, newtype, class, 
and instance definitions as well as top-level variable definitions.

Expressions include variables, constants, applications, let-binding, 
case-analysis, and perhaps some other things I've forgotten.

The binding syntax is shared by top-level bindings, let-bindings, and 
where-bindings. So the "let" keyword licenses binding in an expression, 
but other statements like data, class, or instance definitions can never 
occur within expressions[1]. Also, expressions (variables, 
applications,...) cannot occur at the top-level.


[1] Dave MacQueen notes that SML _does_ allow the definition of data 
types within expressions. However, noone is really sure what on earth 
this means. As I mentioned in the typeclass thread, I've been working on 
trying to figure that out :)



> Unfortunately this is untrue when Unicode is taken into account. Consider
> the Haskell fragment:
> 
> def xyzzy = let y = 1 in <expr>;

Right, I sent an correction to my claim shortly after that mail. Though, 
technically, this example wouldn't be a problem even with Unicode, since 
the "in" keyword closes the block opened by "let" and moreover it's all 
on one line. The only way to get an error would be if <expr> contained a 
newline and one of those lines was indented less than "def". Which can't 
happen since "def" starts at the first character on the line >:)

But yes, you're right that Unicode throws a wrench in things. As I 
mentioned in my correction, part of the reason I misspoke is that the 
accepted style guidelines for writing Haskell incorporates a number of 
practices which (mostly unintentionally) serve to defend against 
potential problems like these. And those guidelines were firmly 
entrenched long before anyone started using Unicode syntax regularly in 
Haskell.

-- 
Live well,
~wren


More information about the bitc-dev mailing list