I think it has to do with what the manual describes as being offside. You don't want to be:

| SeqBlock -- Indicates a sequence of items which must be columned aligned, and
where delimiters such as 'in' and ';' are automatically inserted as necessary between
the elements.

Pushed when
1. immediately after a '=' token is encountered in a Let or Member context
2. immediately after a Paren, Then, Else, WithAugment, Try,
Finally, Do context is pushed
3. immediately after any infix token is encountered.
4. immediately after a '->' token is encountered when in a MatchClauses context
5. immediately after an 'interface', 'class', or 'struct' token is encountered in
a type declaration

By on 11/20/2007 9:24 AM ()

i realise that it's possible to get it to work - i just wondered why
my example was wrong. i seem to end up spending about 40% of
my coding time in F# trying to decipher obscure syntax errors.

the #light syntax and all the F# syntax sugar can make for
nice, readable code, but it sure doesn't make things easy when
you get a blunt "syntax error" from the compiler...

1
2
3
4
5
let x = (fun a z ->
    let (s, n) = a
    s + n + z

BTW, what i actually wanted to do originally was along the lines of:

1
2
3
4
let x = function (s, n) -> fun z ->
     s+n+z

which would be a nice compact way to get pattern matching
into an inline function.

there's probably a better way to do it.

By on 11/20/2007 9:37 AM ()

while i'm on the subject, this gets me every time too:

1
2
3
4
5
6
7
8
// this code gives a syntax error.
let f x =
    match x with
    | Some x -> printf "hello %A\n" x
    | _ -> printf "nothing\n"
    99

it took me quite a while to work out that
you need brackets around the match expression.

By on 11/20/2007 9:47 AM ()

I think it has to do with the -> operator. If you indent your second line so that the -> operator begins at or after the one in the first line it will work. Not sure the reasoning behind that but that is what it appears to do.

By on 11/20/2007 9:20 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper