Did you put "#light" at the top of the file?

Also I think you may have had a TAB in your file - if you're not using Visual Studio you might like to use that.

I'll post a complete XML sample on my blog tonight to save you the effort of retyping.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 

#light

open System.Xml

let parse inp =
 "results!"

let inp = "<a />"

let doc = new XmlDocument()

doc.LoadXml(inp)

printf "results = %A\n" (parse "abc")


let failures = ref false
let report_failure s  = 
  prerr_endline ("NO: "^s); failures.contents <- true

By on 4/9/2007 1:15 PM ()

I'm currently using Visual Studio. Putting #light at the top and removing the tab before "results!" seems to have worked. Is #light required at the top of every file where I want it or is it a project wide setting?

Without the #light option, what was causing what I typed to fail?

What would you suggest as far as syntax choice? I'm primarily a C# developer and OCaml compatibility isn't a concern of mine.

Thanks for the help.

By on 4/9/2007 1:23 PM ()

Yes, in every source code file. You should also copy-and-paste (Alt-Enter) #light into fsi.exe when you start it up to put it in the right mode.

I would recommend using #light.

You can use --light on the command line options (e.g. in the project properties), but we don't really recommend that because we encourage you to include the #light when you send questions, post code samples, show your friends etc.

Without the #light

1
2
3
4
5
6
 

let x = f "a"

g x

parses as if you had written

1
2
3
4
 

let x = f "a" g x

which is meaningless. Without #light toplevel expressions need to either follow an explicit ";;", be prefixed with "let _ = ", or be prefixed with "do", e.g.

1
2
3
4
5
6
 

let x = f "a";;

g x;;

OR

1
2
3
4
5
6
 

let x = f "a"

do g x

OR

1
2
3
4
5
6
 

let x = f "a"

let _ = g x
By on 4/9/2007 1:36 PM ()

That makes sense.

Thanks.

By on 4/9/2007 1:40 PM ()
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