|
|
problem only in FSI but not FSC
Last post 09-26-2008, 5:20 by trn. 16 replies.
-
01-27-2008, 10:04 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
problem only in FSI but not FSC
my environment:
mac os x 10.5 leopard
mono 1.2.6
F# Version 1.9.3.14, compiling for .NET Framework Version v1.1.4322
i'm trying out the first code sample in chapter two of Expert F#.
i'm able to compile (modified main.fs) and run the following with no problem:
#light
/// Analyze a string for duplicate words
let wordCount text =
let words = String.split [' '] text
let wordSet = Set.of_list words
let nWords = words.Length
let nDups = words.Length - wordSet.Count
(nWords,nDups)
let showWordCount text =
let nWords,nDups = wordCount text
printfn "--> %d words in the text" nWords
printfn "--> %d duplicate words" nDups
showWordCount "Couldn't put Humpty together again"
showWordCount "the king is dead. long live the king"
-------
output:
--> 5 words in the text
--> 0 duplicate words
--> 8 words in the text
--> 2 duplicate words
but when i try String.split;; in fsi (i start it by cd'ing to the directory containing the FSharp downloads, then typing
mono bin/fsi.exe --no-gui at the shell prompt), I get what seem to be a namespace problem(??).
> String.split;;
String.split;;
-------^^^^^^
stdin(1,7): error: FS0039: The value, constructor, namespace or type 'split' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
could someone help? can i resolve this problem by adding something to the lib path via #I? if so, what should I add?
i think i'm looking for the assembly containing Microsoft.FSharp.Core ??
also, will #r "Microsoft.FSharp.Core";;
or #r "Microsoft.FSharp.Core.dll";;
work?
somehopw i'm getting the following error message when I do either of the #r commands.
stdin(3,0): error: Unable to find the file Microsoft.FSharp.Core in any of
/Library/Frameworks/Mono.framework/Versions/1.2.6/lib/mono/2.0
/Users/myusername/FSharp-1.9.3.14/../assembly/GAC/Microsoft.Office.Interop.Owc11/11.0.0.0__71e9bce111e9429c
/Users/myusername/FSharp-1.9.3.14/Xceed Components/Bin/.NET/Signed DLLs
/Users/myusername/FSharp-1.9.3.14
/Users/myusername/FSharp-1.9.3.14/bin.
thanks for any help!!
|
|
-
01-27-2008, 10:31 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
Re: problem only in FSI but not FSC (more info/follow up)
something strange ...
I tried other functions in Microsoft.FSharp.Core.String and did not encounter any problem:
> String.for_all;;
val it : ((char -> bool) -> string -> bool) =
> String.map;;
val it : ((char -> char) -> string -> string) =
but
> String.Split;;
String.Split;;
-------^^^^^^
stdin(5,7): error: FS0039: The value, constructor, namespace or type 'Split' is not defined.
stopped due to error
|
|
-
01-27-2008, 10:44 |
-
certen
-
-
-
Joined on 04-17-2007
-
-
Posts 48
-
-
|
Re: problem only in FSI but not FSC (more info/follow up)
I wonder if
open System;;
would help ?
// Can.
|
|
-
01-27-2008, 11:35 |
-
dsyme
-
-
-
Joined on 02-15-2006
-
-
Posts 688
-
-
|
Re: problem only in FSI but not FSC
The current F# dsitribution still by default uses Mono's ".NET 1.0" configuration by default. Unfortunately String.split is only supported when using the .NET 2.0 configuration. I apologise that the first sample of the book uses something that is not seamlessly supported on Mono: it was a silly oversight.
I'm sure someone on the forums will contribute a String.split implementation you can put just before your code, and we've added String.split to the latest F# release.
We are also looking at using the .NET 2.0 configuration by default on Mono. You can do this yourself by removing your current installation of F#, unpacking it again, and deleting or commenting out the following lines from install-mono.sh before you install:
echo "Replacing fsi.exe and fsc.exe with programs that run under .NET 1.0..."
cp -p bin/fsi.exe bin/fsi-old.exe
cp -p bin/fsi10.exe bin/fsi.exe
You can also avoid reinstalling by copying back the fsi-old.exe, as long as you haven't run install-mono.sh twice already...
Please let us know if that works.
Kind regards
don
|
|
-
01-27-2008, 16:38 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
Re: problem only in FSI but not FSC
Hi Don,
Thanks for the suggestions (which seemed to work for the most part but note the "display/delayed echo/buffer(?)" problems reported below. not sure if other Mono/Mac OS X users have encountered similar problems or if problems are specific only to mono/mac os x users but ...).
I did both:
(1) delete current install, unpack again, comment out the two lines you suggested, and run the new install-mono.sh;
(2) delete current install, unpack again, run install-mono.sh, cp fsi-old.exe to fsi.exe (which should target .Net 2.0).
In both cases, I was able to verify that fsi is now using the 2.0 binaries, but for some reason I'm having "display" problems. My experience is such that I can't seem to see what I'm typing initially (i might be typing String.split;; but what I see echoed
might be .split;; and fsi gets as input "tring.split;;). I have a really fast MacBook (Intel dual-core) and 4 Gig of RAM so I'm sure the problems are being caused by something else. unfortunately, i dont know what those are :-(
$ mono bin/fsi.exe --no-gui
MSR F# Interactive, (c) Microsoft Corporation, All Rights Reserved
F# Version 1.9.3.14, compiling for .NET Framework Version v2.0.50727
NOTE:
NOTE: See 'fsi --help' for flags
NOTE:
NOTE: Commands: #r ;; reference (dynamically load) the given DLL.
NOTE: #I ;; add the given search path for referenced DLLs.
NOTE: #use ;; accept input from the given file.
NOTE: #load ...;;
NOTE: load the given file(s) as a compilation unit.
NOTE: #time;; toggle timing on/off.
NOTE: #types;; toggle display of types on/off.
NOTE: #quit;; exit.
NOTE:
NOTE: Visit the F# website at http://research.microsoft.com/fsharp.
NOTE: Bug reports to fsbugs@microsoft.com. Enjoy!
> .split;;
tring.split;;
^^^^^^
stdin(1,0): error: FS0039: The namespace or module 'tring' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
> Striing.map;;
Striing.map;;
^^^^^^^^
stdin(2,0): error: FS0039: The namespace or module 'Striing' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
> String.map;;
val it : ((char -> char) -> string -> string) =
> #quit;;
- Exit...
|
|
-
01-27-2008, 16:43 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
Re: problem only in FSI but not FSC
not sure if this prints out better, but here goes:
========================
Note particularly the following:
> .split;;
tring.split;;
^^^^^^
stdin(1,0): error: FS0039: The namespace or module 'tring' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
> Striing.map;;
==================================
$ mono bin/fsi.exe --no-gui
MSR F# Interactive, (c) Microsoft Corporation, All Rights Reserved
F# Version 1.9.3.14, compiling for .NET Framework Version v2.0.50727
NOTE:
NOTE: See 'fsi --help' for flags
NOTE:
NOTE: Commands: #r ;; reference (dynamically load) the given DLL.
NOTE: #I ;; add the given search path for referenced DLLs.
NOTE: #use ;; accept input from the given file.
NOTE: #load ...;;
NOTE: load the given file(s) as a compilation unit.
NOTE: #time;; toggle timing on/off.
NOTE: #types;; toggle display of types on/off.
NOTE: #quit;; exit.
NOTE:
NOTE: Visit the F# website at http://research.microsoft.com/fsharp.
NOTE: Bug reports to fsbugs@microsoft.com. Enjoy!
> .split;;
tring.split;;
^^^^^^
stdin(1,0): error: FS0039: The namespace or module 'tring' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
> Striing.map;;
Striing.map;;
^^^^^^^^
stdin(2,0): error: FS0039: The namespace or module 'Striing' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
> String.map;;
val it : ((char -> char) -> string -> string) =
> #quit;;
- Exit...
|
|
-
01-27-2008, 17:03 |
-
dsyme
-
-
-
Joined on 02-15-2006
-
-
Posts 688
-
-
|
Re: problem only in FSI but not FSC
Try "fsi --no-readline". If anything GUI-related fails try "fsi --no-readline --no-gui"
Notice you spelt "Striing" wrong above in "String.map"
Thanks!
don
|
|
-
01-27-2008, 18:46 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
Re: problem only in FSI but not FSC
thanks! doesn't seem to have an effect.
Tthree things I noticed:
(1) with fsi for Net 2.0, I need to type Shift-s twice to get String.split;; to run without getting any error messages (even though the display might be screwed up e.g., it'll show String.split;; or tring.split;; even though I typed SString.split;; and fsi will get the "correct" input)
(2) If I made a mistake and I hit delete or backspace, my display does not update correctly (e.g., I typed String.map;; my screen shows String.map;; fsi gets ing.map and I get an error message;; OR i type StrString.map;; my screen shows StrString.map;; i get some syntax error messages but then at some point fsi seems to get the "correct" input (see trace reproduced below)
(3) I dont get these problems when i switch back to fsi for .Net 1.x.
====================
FSI for Mono .Net 2.x
====================
mono fsi.exe --no-readline --no-gui
MSR F# Interactive, (c) Microsoft Corporation, All Rights Reserved
F# Version 1.9.3.14, compiling for .NET Framework Version v2.0.50727
NOTE:
NOTE: See 'fsi --help' for flags
NOTE:
NOTE: Commands: #r ;; reference (dynamically load) the given DLL.
NOTE: #I ;; add the given search path for referenced DLLs.
NOTE: #use ;; accept input from the given file.
NOTE: #load ...;;
NOTE: load the given file(s) as a compilation unit.
NOTE: #time;; toggle timing on/off.
NOTE: #types;; toggle display of types on/off.
NOTE: #quit;; exit.
NOTE:
NOTE: Visit the F# website at http://research.microsoft.com/fsharp.
NOTE: Bug reports to fsbugs@microsoft.com. Enjoy!
> tring.split;;
val it : (char list -> string -> string list) =
> StrString.map;;
StrString.map;;
---^^
stdin(2,3): error: syntax error.
>
StrString.map;;
----^^
stdin(2,4): error: syntax error.
>
StrString.map;;
-----^^
stdin(2,5): error: syntax error.
> val it : ((char -> char) -> string -> string) =
> #quit;;
- Exit...
=================================
FSI for Mono .Net 1.x
(note: i didnt use --no-readline,
but didnt experience "display" problems either)
I only had to type Shift-S once; for String.map;;
I typed StrString.map;;
=================================
mono fsi.exe --no-gui
MSR F# Interactive, (c) Microsoft Corporation, All Rights Reserved
F# Version 1.9.3.14, compiling for .NET Framework Version v1.1.4322
NOTE:
NOTE: See 'fsi --help' for flags
NOTE:
NOTE: Commands: #r ;; reference (dynamically load) the given DLL.
NOTE: #I ;; add the given search path for referenced DLLs.
NOTE: #use ;; accept input from the given file.
NOTE: #load ...;;
NOTE: load the given file(s) as a compilation unit.
NOTE: #time;; toggle timing on/off.
NOTE: #types;; toggle display of types on/off.
NOTE: #quit;; exit.
NOTE:
NOTE: Visit the F# website at http://research.microsoft.com/fsharp.
NOTE: Bug reports to fsbugs@microsoft.com. Enjoy!
> String.split;;
String.split;;
-------^^^^^^
stdin(1,7): error: FS0039: The value, constructor, namespace or type 'split' is not defined.
stdin(0,0): error: FS0039: The value or constructor 'it' is not defined.
stopped due to error
> String.map;;
val it : ((char -> char) -> string -> string) =
> #quit;;
- Exit...
|
|
-
01-27-2008, 18:50 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
Re: problem only in FSI but not FSC
(2) should have read:
(2) If I made a mistake and I hit delete or backspace, my display does not update correctly (e.g., I typed String.map;; my screen shows String.map;; fsi gets ing.map and I get an error message;; OR i type StrString.map;; my screen shows StrString.map;; i get some syntax error messages but then at some point fsi seems to get the "correct" input (see trace reproduced below)
|
|
-
01-27-2008, 18:57 |
-
fsharpfan
-
-
-
Joined on 01-27-2008
-
-
Posts 17
-
-
|
Re: problem only in FSI but not FSC
=================================
FSI for Mono .Net 1.x
(note: i didnt use --no-readline,
but didnt experience "display" problems either)
I only had to type Shift-S once; for String.map;;
I typed StrString.map;;
=================================
should have read
=================================
FSI for Mono .Net 1.x
(note: i didnt use --no-readline,
but didnt experience "display" problems either)
I only had to type Shift-S once; for String.map;;
I typed StrString.map;;
=================================
|
|
-
02-03-2008, 5:21 |
-
SlideGuitarist
-
-
-
Joined on 12-08-2007
-
Reston, VA
-
Posts 10
-
-
|
Re: problem only in FSI but not FSC
Maybe I'm not tracking this discussion accurately, but isn't the problem simply that "split" starts with a lower-case 's', and you typed it with an upper-case 's'? "split()" is a static function of F#'s String module.
> String.split [' '] "Tony Albert Nassar";; val it : string list = ["Tony"; "Albert"; "Nassar"] >
|
|
-
02-12-2008, 23:53 |
-
cstaszak
-
-
-
Joined on 02-11-2008
-
San Diego, CA
-
Posts 6
-
-
|
Re: problem only in FSI but not FSC
As others have reported, using fsi-old.exe fixed my larger issues as well. However, the --no-readline option definitely messes up my terminal -- console echo is missing on startup and somehow color highlighting goes crazy on me. If I explicitly use the --readline option, everything is much happier -- except I have noticed that the backspace key is no longer mapped properly and I need to use ctrl-h instead. Does anyone have an idea what is clobbering the terminal settings?
My setup:
OS X 10.5.1 Terminal.app
Mono JIT compiler version 1.2.6 (tarball)
F# Version 1.9.3.14, compiling for .NET Framework Version v2.0.50727
-- Chris http://www.staze.net
|
|
-
09-17-2008, 2:59 |
-
trn
-
-
-
Joined on 09-18-2008
-
Hong Kong
-
Posts 5
-
-
|
Re: problem only in FSI but not FSC
I am using Windows version with Visual Studio Shell integration. I had encountered the same problem.
However, the IDE suggested me to add FSharp.PowerPack.dll and the problem was gone.
It works in the compiled version but not the interactive console. I don't know the corresponding name space to use.
I am not sure if this also applies in your Mac OSX environment
trn
http://fslang.blogspot.com
|
|
-
09-18-2008, 11:44 |
-
David
-
-
-
Joined on 09-18-2008
-
-
Posts 46
-
-
|
Re: problem only in FSI but not FSC
I had the problem.
Open up the F# Interactive.
And, type the line starting with
#r @"FSharp.PowerPack";;
Then, it work.
|
|
-
09-23-2008, 4:46 |
-
trn
-
-
-
Joined on 09-18-2008
-
Hong Kong
-
Posts 5
-
-
|
Re: problem only in FSI but not FSC
Thanks a lot, David. It works.
Is it possible to load the DLL by default so that we don't need to type this command everytime we open up the F# Interactive ?
trn
http://fslang.blogspot.com
|
|
Page 1 of 2 (17 items)
1
|
|