Did you mean "open" Microsoft.FSharp.Compatibility.FSharp instead of "module"?

By on 10/21/2010 8:58 AM ()

Hi Brian,

Assuming you mean Microsoft.FSharp.Compatibility.OCaml, we now get:

Error FS0039: The namespace 'Compatibility' is not defined.

By on 10/22/2010 2:40 AM ()

Aha, it looks like that stuff lives in FSharp.PowerPack.Compatibility.dll, whereas you've just reference FSharp.PowerPack.dll.

(See the very bottom of

[link:fsharppowerpack.codeplex.com]

)

By on 10/22/2010 8:20 AM ()

Cheers Brian.

I'm making a fair amount of progress now.

The syntax for records vis-a-vis module names seems to have changed, though, so I can no longer write

i.Pdfio.input_byte ()

(record i, containing function Pdfio.input_byte)

and adding brackets:

i.(Pdfio.input_byte) ()

seems to make F sharp think i is an array.

Only adding

open Pdfio

seems to work, and that's horrible. Is there something I'm missing?

By on 10/24/2010 7:04 AM ()

(record i, containing function Pdfio.input_byte)

Can you show some code for the declarations here? Records are not my forte and I am having trouble picturing what this means.

By on 10/24/2010 7:09 AM ()

So, in pdfio.mli we have

type pos = int

type input =

{pos_in : unit -> pos;

seek_in : pos -> unit;

input_char : unit -> char option;

input_byte : unit -> int;

in_channel_length : unit -> pos;

set_offset : pos -> unit}

We than have functions

input_of_string : string -> input

input_of_array : int array -> input

input_of_channel : in_channel -> input

input_of_file : string -> input

etc, all of which return an 'input' record, which is a bunch of functions for doing input.

So, to use it from another module, we might do

let i = Pdfio.input_of_file "myfile.txt" in

let b = i.Pdfio.input_byte () in

Printf.printf "Byte was %i" b

I think ocaml deals with the i.Pdfio.input_byte well because it can use the capitilisation of the "Pdfio" to know it's a module name - perhaps F sharp can't do the same...

By on 10/25/2010 4:48 AM ()

I see, F# doesn't work that way, it would be "i.input_byte" even if you haven't opened the module.

By on 10/25/2010 9:04 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