I find the language specification included with the manual and available from
[link:research.microsoft.com]
to be the most complete reference for these kind of things. Don't be intimidated by the terseness of the specification, after some familiarization it's quite easy to read.

By on 9/14/2007 10:03 AM ()

I'm new to ML and F# so excuse my terminology, which is probably
wrong, but I was also trying find a reference for the F# operators. I searched
for what seemed like ages in that page, but it doesn't actually seem to
define the default semantics of the the various overloadable operators
(e.g. !).

Perhaps there's a page somewhere which defines the usual semantics
of the operator functions, but I haven't found it yet.

Any suggestions?

By on 9/28/2007 6:58 AM ()

:?> is a downcast this is a cast that can fail, for example casting from object to a string. ( :> is used from upcast, a cast that can't fail, i.e. casting from string to object)

:? is a type check, is this object castable to this type, I believe it is exactly the equivalent of "is" in C#.*

As far as I'm aware there's no definite guide to how the over loaded operators behave, but the to F# is available so its pretty easy to figure out from that. From prim-types.fs we see:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        let inline (+) (x: ^a) (y: ^b) : ^c = 
             (^a: (static member (+) : ^a * ^b -> ^c) (x,y))
             when ^a : int32       and ^b : int32      = (# "add" x y : int32 #)
             when ^a : float       and ^b : float      = (# "add" x y : float #)
             when ^a : float32     and ^b : float32    = (# "add" x y : float32 #)
             when ^a : int64       and ^b : int64      = (# "add" x y : int64 #)
             when ^a : uint64      and ^b : uint64     = (# "add" x y : uint64 #)
             when ^a : uint32      and ^b : uint32     = (# "add" x y : uint32 #)
             when ^a : nativeint   and ^b : nativeint  = (# "add" x y : nativeint #)
             when ^a : unativeint  and ^b : unativeint = (# "add" x y : unativeint #)
             when ^a : int16       and ^b : int16      = (# "conv.i2" (# "add" x y : int32 #) : int16 #)
             when ^a : uint16      and ^b : uint16     = (# "conv.u2" (# "add" x y : uint32 #) : uint16 #)
             when ^a : sbyte       and ^b : sbyte      = (# "conv.i1" (# "add" x y : int32 #) : sbyte #)
             when ^a : byte        and ^b : byte       = (# "conv.u1" (# "add" x y : uint32 #) : byte #)
             when ^a : string      and ^b : string     = (# "" (System.String.Concat((# "" x : string #),(# "" y : string #))) : ^a #)

Roughly speaking this says if there is an IL instrustion that can handle this type of addation use that, if there's a static plus operator defined on the object use that.

By on 9/28/2007 8:17 AM ()

See also [link:research.microsoft.com].

The types are elided, but can be found via Intelliense or prim-types.fsi.

Internally we've completed documentation for these and that should appear when we refresh the docs.

Don

By on 9/28/2007 10:44 AM ()

The types are elided, but can be found via Intelliense or prim-types.fsi.

Just wondering: is it possible to get Intellisense working under Visual Studio 2003?
It sounds like a really useful tool, but I don't have access to VS 2005.
In fact, just an F# functional interface would be as good for me - e.g. provide some source
code and an offset and it gives type/other info for that point in the code.
I doubt it can be that simple though!

By on 10/2/2007 7:55 AM ()

A script "alternative-install-vs2003.bat" is supplied to make install the vs intergration with vs 2003, I would have assumed that would make the intellisense work. Is this not the case?

I would however highly recommend upgrading to vs 2005 if possible, its not just the vs environment, its the fact that vs 2005 comes with framework 2.0 which supports generics, and working with generic types from libraries generally has a much more natural feel in F#.

By on 10/3/2007 4:44 AM ()

A script "alternative-install-vs2003.bat" is supplied to make install

the vs intergration with vs 2003, I would have assumed that would

make the intellisense work. Is this not the case?

it doesn't appear to. i've tried the key combo, and looking in the Add-in Manager,
but no sign of Intellisense. as VS starts, it shows "F# for Visual Studio" in
the installed items panel, but maybe that just means it knows i've
got the compiler installed and knows how to syntax-highlight .fs files.

i'd like to upgrade to VS 2005, but i have to live by university policy, which currently
doesn't include it in their installed apps. i'm trying to bug 'em about it.

its not just the vs environment, its the fact that vs 2005 comes with framework 2.0 which supports generics

i'm not sure i understand the implications of that... does that mean that
i can't export generic classes/functions outside of my F# dll?
i seem to have no problem using Seq<'a>, etc.

PS. if i wished to explore the types and interfaces exported by a 3rd party DLL
with inadequate documentation, is there a more convenient way to do so other
than guessing at type names and writing code to pretty-print System.Type?
i thought there might be some functionality in VS to do that, but if so, i haven't
found it yet. nor have i found the right google search...

By on 10/3/2007 8:02 AM ()

F# itself supports generics even when targeting framework 1.1, so assemblies written in F# can be "generic" but only to other F# programs. Achives this by storing extra meta as a resource in the assembly headering and then erasing the generic parameters as part of the compilation process.

This means if your targeting framework 1.1 you will find your method signatures different to if you targeting framework 2.0

For example

let f x = x

would look like this to C# on framework 1.1

object f(object x);

but would look like this to C# on framework 2.0

T f<T>(T x);

If you want to find out about what's inside any assembly, then you need reflector. You will be amazed what this tool will tell you: [link:www.aisto.com]

By on 10/3/2007 8:45 AM ()

ah, is that what it means when i get the following warning?

stdin(968,14): warning: FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type 'obj'.If you want to find out about what's inside any assembly, then you need

reflector. You will be amazed what this tool will tell you: [link:www.aisto.com]

thats exactly what i was after, thanks very much. i'd just started down the pretty printer
route, and i couldn't believe just how many types were involved in defining System.Type
(not that the MSDN online library made looking at the documentation any easier)

By on 10/3/2007 9:23 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