Seq.generate_using is MIA - f#

I'm trying to use the Seq.generate_using function but unfortunately, I don't seem to be able to find it. I thought it would be living here:
Microsoft.FSharp.Collections.Seq.generate_using
But it doesn't. I am getting the error listed below.
C:\Users\Owner\Documents\Visual Studio
2008\Projects\fsharp1\Program.fs(54,63):
error FS0039: The value, constructor,
namespace or type 'generate_using' is
not defined. A construct with this
name was found in
FSharp.PowerPack.dll, which contains
some modules and types that were
implicitly referenced in some previous
versions of F#. You may need to add an
explicit reference to this DLL in
order to compile this code.

According to the Sept 2008 CTP Release Notes:
The F# library is split into two
components. FSharp.Core.dll: Contains
the core F# libraries, which will be
stabilized and versioned infrequently.
FSharp.PowerPack.dll: Contains
additional useful F# libraries and
tools which will version more
frequently, and allow continued
innovation on top of the core F#
language and libraries.
Some methods in the Seq module were moved into the FSharp.PowerPack assembly, so you can only get those methods by doing the following:
If you're using Visual Studio, open your Solution Explorer, right-click on the project file, choose "Add Reference", and add "FSharp.PowerPack.dll".
If you're using a script file or fsi, then type #r "FSharp.PowerPack";; to load the assembly.
Now you should be able to call Seq.generate_using.

The #r "FSharp.PowerPack";; works for me but the addition of PowerPack to my solution does not. I am trying to use HashSet<>.

Related

F# IDE scripting support for accessing internal types in referenced assemblies

Usually for non-scripting C#/F# project, one can specify a InternalsVisibleTo attribute in the dependency assembly and be able to get intellisense for its internal types in the IDE. But in F# scripting, how would I configure the dependency assembly with respect to the IDE I'm using in order to get intellisense for internal types? Of course in order for the script to run by fsi I assume I'd need something like
[assembly:InternalsVisibleTo("fsi")]
But in order to get the IDE support should I also specify every known IDE in the dependency assembly? That doesn't seem to scale very well.
I did a code search and found this where fsc, fsi, compiler service assembly, and their strong name versions, etc. are all specified, seemingly to accommodate IDEs. This is exactly what concerns me and I don't want to litter my assemblies with these. Is there a better way?

F# interactive throws NotImplementedException in PCLStorage

I'm getting NotImplementedException trying to use PCLStorage.FileSystem.Current in F# interactive.
I downloaded PCLStorage with NuGet, right clicked on the reference and clicked "Send to F# interactive"
I'm working with VS2015 update 1, and I've re-installed the package as suggested in this answer
How can I get PCLStorage to work in F# interactive?
--> Referenced 'C:\Users\amade\Documents\GitHub\audioExperiments\src\Audio\packages\PCLStorage.1.0.2\lib\portable-net45+wp8+wpa81+win8+monoandroid+monotouch+Xamarin.iOS+Xamarin.Mac\PCLStorage.dll'
> open PCLStorage;;
> PCLStorage.FileSystem.Current;;
> System.NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation.
at PCLStorage.FileSystem.get_Current()
at <StartupCode$FSI_0017>.$FSI_0017.main#()
Stopped due to error
The PCL you've referenced is the one designed to target all platforms (Xamarin, Windows desktop, Windows phone etc). This dll is simply used as a means of defining all of the individual methods as part of the bait and switch PCL technique http://log.paulbetts.org/the-bait-and-switch-pcl-trick/ If you want to use the library with FSI then you'll need to add a specific reference to the appropriate platform's DLL. In this case you'll want to refer to the windows desktop version of the project which you downloaded from NuGet.

Using COM DLLs with FSI

Is there a way within FSI that I can reference and use registered COM components?
In a normal .fs compiled program I can simply reference the component in question and then open the relevant generated namespace(s). In a .fsx file, however, I can't seem to replicate this behaviour. I have tried using #r to reference the .dll directly, and I have tried using #I to point to the directory followed #r both with the library's "friendly" name and the file name, but nothing seems to work.
Are you only able to reference .NET assemblies from a .fsx? I don't really want to have to write/gen a wrapper assembly. I am hoping there might be a way to force FSI to take whatever steps the normal executable takes in order to provide the interop layer.
When you add a reference to a COM component in Visual Studio, it invokes a tool to generate a wrapper (standard .NET assembly) and then references the wrapper.
If you want to reference COM from fsx, you'll need to generate the wrapper yourself (or find the one generated by Visual Studio?) The tool that generates the wrapper that is called TlbImp.exe (see Type Library Importer on MSDN).

F# interactive: Reference a project in currently open solution

I would like to use the F# interactive console with the projects in the currently open solution in Visual Studio 2010. Is there a quick and easy way to add a reference in the F# interactive console to reference projects in the currently open solution?
I've got lines like this at the top of my .fs file:
#if INTERACTIVE
#r #"C:\path\to\some.dll"
#I #"C:\Users\bford\path\to\a\project\in\this\solution\bin\Debug"
#r "Project.name"
#endif
Alt-Enter now drops me into fsi with all the required stuff loaded
If it's a project you reference often, you can add an 'always' reference to the FSI command line, under Tools->Options->F# Tools->F# interactive options.
Add a -r switch like:
-r "C:\Users\yaddayadda\MyDll.dll"
I don't think there is any direct way to reference a project in the solution. The best way I can think of is to add a FSX file somewhere to your project with the #r directive:
#r #"bin\Debug\YourProject.dll"
Then you can at least reference the compiled DLL file simply by hitting Alt+Enter in Visual Studio. As far as I know, you cannot reference the project - you can only reference an assembly.
Currently, F# Interactive is really disconnected from the project system in Visual Studio. I suppose that closer integration would be quite useful (but probably difficult to provide).
Now in Visual Studio 2013 you can add a reference to the F# interactive window by right clicking on the referenced dll and clicking "Send to F# interactive".
I would think it should be straightforward to reference the current project, obtain the list of references it contains, and then optionally generate a list of #r (and possibly #i) statements for the interactive session being created, referencing the dll of the project itself as well.
For example: "fsi /i:pathOfLib1 /r:lib1 /i:pathOfLib2 /r:lib2 ...."
PS: base on the MSDN article it doesn't appear that library names can include their path prefixes hence the separate into /i and /i : http://msdn.microsoft.com/en-us/library/dd233172%28v=vs.100%29.aspx
It would be good if the Visual Studio F# Interactive Options menu allowed for the stipulation of a startup script that the invocation could pass to FSI via the "--use:" directive. Such a script could then be passed solution metadata that allows for the environments to be more integrated such as loading latest project outputs.

how to use system.xml.dll in delphi

I downloaded the system.xml.dll, then added it to my Delphi code as following:
uses system.xml;
etc...
When I try to compile the project, the following message appears:
file not found system.xml.dcu.
Can anyone guide me how to solve this problem?
Thanks.
The uses clause in Delphi refers to Delphi units, either compiled in a *.dcu file or a *.pas source file that the compiler will use to generate the corresponding *.dcu that is needed.
You cannot just reference the DLL itself.
To use your DLL, you would need at least a unit that would expose in a Pascal way the DLL interface or parts of it.
It can be the Pascal translation of a C header file or just declaring some external routines from the dll to load statically with your program...
What you probably need to reference to work with XML in Delphi are XMLIntf and maybe xmldom.
Have you looked at what the XML Data binding wizard or the XML Mapper Tool can do for you?
Note: I assumed you were working with Delphi Win32. And AFAIK system.xml.dll is part of the .NET world.
If you are using Delphi for .Net you need to add a reference to the system.xml.dll assembly to your project.
If you are using Delphi (Win32), then in order to be able to use .NET assemblies (DLLs), you have the option of using COM interfaces. Follow below steps:
Open the project you want to use it in.
Use Component menu.
Select "Import Type Library"
Select the DLL you want to use.
Follow the next steps as given by wizard.
This will generate a source file which is essentially a wrapper. You can call function of that wrapper as you need.
Please note that using above method will mean that .NET framework must be present on the computer running your application.

Resources