Geeks With Blogs
A Software Engineering Blog by Nick Holmes
To use LINQ To SQL, we need a Data Context object to provide our point of entry. It might be possible to use a System.Data.Linq.DataContext object directly, but its more usual to derive from this class to make a database specific version. Additionally, we need classes to represent our "entities". These define the mapping to the tables (or views) and ......

[Update: This blog post was orignally posted in early 2008, in another blog. Things have changed a little in F#, and Ted Nedward has provided updated information related to this, showing how to create data contracts in F#] On the road to a really interesting Web Service, I increased the complexity of my "could-not-be-simpler" web service one notch, ......

I had half an hour to fill while I waited for a large download, on my slow connection. I'd thought about re-implementing my C# WCF test host in F#. It didn't look too complex, and indeed it wasn't: #light #I @"C:\Program Files\Reference Assemblies\Microsoft\Framew... #r "System.ServiceModel.dll" #r "Server.dll" open System open System.ServiceModel ......

I tidied up the F# web service, mainly by factoring out an interface for the web service. Without the attributes it looks like this: type ITestWebService = abstract TestMethod: Param:string -> string type TestWebService() = interface ITestWebService with member x.TestMethod s = "Hello " + s; However, I noticed when I was setting up the C# host, I ......

For all the power and flexibility that WCF provides, creating a basic web service in C# is easy enough. Essentially, it's just a POCO adorned with some special attributes. Doing the same thing in F#, then, should also be easy enough. I tried this: #light #I @"C:\Program Files\Reference Assemblies\Microsoft\Framew... #r "System.ServiceModel.dll" ......

I previously said that C#’s lambda functions were not curried, and it wasn’t possible to partially apply them. However, it’s usually possible to manually curry functions, if you need to. Here is an example: static void Main(string[] args) { int t = f(1)(3)(5)(7); Console.WriteLine("{0}", t); var g = f(1); var h = g(3); var i = h(5); int j = i(7); Console.WriteLine("{0}", ......

All this currying and partial application stuff is all very interesting, but surely its has to have some kind of run-time performance hit. What if I just want to keep things straightforward? Firstly, if we have a function that takes only a single argument, there is nothing to curry. It makes no sense to call a function with no arguments, so your only ......

In my last two posts, I described how F# transforms functions with more than one argument into chains of functions with a single argument. Strictly speaking, all functions in F# must have exactly one argument, and return exactly one result. There is a special type, unit, which can be used as a dummy when no argument or return is required, like void ......

OK, so you define a function that takes 2 parameters, but you actually get a function that takes 1 parameter, and returns a function that will take the second parameter and return the final result. Hmm, this raises lots of questions. What happens if the function has more than two parameters? >let f a b c = a + b + c is of type val f : int -> int ......

I’ve been spending some time recently looking at F# - I have a specific task in mind to which F# seems very well suited, so the motivation is there! After many years doing C then C++ and now C#, it’s easy to fall into the trap of thinking some things work just the same in F#. One example of this is functions. I was happily experimenting with some code, ......

Copyright © Nick Holmes | Powered by: GeeksWithBlogs.net