I asked the following question on hubfs.net

This might be a newbie question about type inference, but it can help beginners like me.

I am using the query below – which sorts items by date. This gives the warning: This lookup uses a deprecated feature, where a class type is inferred from the use of a class field label…

Query.query <@ (Seq.sort_by (fun i -> i.DateAdded) (seq { for item in ctx.BarterItems do yield item }))   |> Seq.take 50 @>;

In the seq { … } expression, the type of item is identified as “Item” correctly, through ctx.BarterItems. Why wouldn’t this be used to infer “i” in “fun i -> i.DateAdded“? ; Seq.sort_by being (<’a>-><’key>) -> seq<’a> -> seq<’a>

Explicitly identifying the type will remove the warning, as below:
Query.query <@ (Seq.sort_by (fun (i:Item) -> i.DateAdded) (seq { for item in ctx.BarterItems do yield item }))   |> Seq.take 50 @>;

Brian McNamara pointed out:

Type inference in F# works left-to-right through an expression; for example

let s = seq { yield “foo”; }

let s2 = s |> Seq.sort_by (fun x -> x.Length) // compiles

//let s2 = Seq.sort_by (fun x -> x.Length) s // does not

In the first one, we already know that the elements of ’s’ are type ’string’ by the time we reach the lambda body and “x.Length”.  In the second one, we don’t.  This is one of the things that makes the pipelining style so attractive.

As Brian pointed out, thats a good use case for the Pipelining operator.

My new query looks like:
Query.query <@ seq { for item in ctx.BarterItems do if item.ItemType = "book" then yield item }
|> Seq.sort_by (fun i -> i.DateAdded) |> Seq.take 50 @>;

Inference now works, since the type can be inferred left to right.

Meanwhile you can read more on ML type inference.

Just discovered GrooveShark. More that 7 million songs that could be played. Wow!

China blocks YouTube

March 24th, 2009

China blocks YouTube for some videos of the security forces beating up Tibetan monks. I remember last year they blocked SourceForge.net, the large Open Source software repository. All because one of the million sub-projects under SourceForge put up a Tibetan protest banner. Oh, they block Wikipedia too.

Don’t you just love the communists?

I am not Tibetan, and I know no Tibetans. But I myself wouldn’t want to live under such a repressive regime. FREE TIBET!

Microsoft just announced some interesting enhancements to Azure, including Full-Trust roles. This makes life much better for anyone trying to use F# on Azure.

The earlier workaround requires adding more than 20 references, and takes 10 TIMES longer to get compiled.

George Carlin Collection

March 1st, 2009



The Ten Commandments


George Carlin on Death


Saving the Planet

whats-wrong-with-the-pic

Nothing really. I say the picture is Spot On!

whats-wrong-with-the-pic-2

Dear InterSystems, times they are a changin!
I suggest replacing the sports car with a Model T, though.

Frank Zappa!

January 15th, 2009

img_2977-small

Acrylic on Canvas.

I am Free.

January 11th, 2009

I am not a Mac

I am not a PC

I am Free

Seen here on comments.

This issue should resolve itself.

December 31st, 2008

Funny quote from Microsoft on ZuneInsider.

Q:  What is Zune doing to fix this issue?
The issue should resolve itself.

Apparently, the bug becomes self-aware on Jan 1 2009. I am scared.

Woman in Clay

December 30th, 2008

img_2980-small

Soft Pastels and Oil Pastels, Canvas.

Inspiration or Interpretation.

  1. Sphinx?
  2. Male organ?