Sunday, April 20, 2014

Quick Cycling Break

Since I didn't get to do a Norfolk break on my bike last year, I did a quick jaunt just before Easter, getting the last of the really good weather before it went downhill for the holiday weekend.

And in much better weather than when I was there five years ago, I decided to head south to Castle Acre and exorcise the bad memories -- and not end up at the Gin Trap for lunch both days.

Cattle at Houghton

Great Massingham

The very nice pub (the Dabbling Duck) I stopped at for refreshment is just past the red car -- if I'd known it was there I wouldn't have needed any picnic supplies. The bar snack menu showed quite clearly that their chef knows the way to a man's heart -- it starts with delicacies such as chips triple fried in beef dripping with curry sauce, and crumpets with bone-marrow and Marmite butter, before getting really serious about the fat and carbs. It made the large pork pie, Scotch egg and Babybel cheese I'd packed look like a virtuous choice!

Castle Acre Priory

As it happened, the weather being so warm I didn't need sleeves, after spending four hours in the saddle, I realised over supper that I had caught the sun, and was going slightly pink, not having had quite enough shirtsleeves weather to pick up a tan incrementally.

Thursday was going to be the Gin Trap lunch day, and a variation on the usual up the coast from Sandringham -- the dry weather meant that the Peddars Way was light off-roading, as was the unmade track near West Newton.

The Peddars Way

The Peddars Way

The work going on at Ringstead Mill a couple of years ago was now done.

Ringstead Mill

Ringstead Mill

The day having been cloudy and cool, I hadn't needed to bare my arms; and soon after I left the Gin Trap, it started raining, though only staying a sprinkle, not like on previous occasions, curtailing the amble back to base.

So, nothing too strenuous, 36.5 and 36.9 miles respectively, for the first real long rides of the year.

Sunday, April 06, 2014

Fun with destructuring pattern matching -- a well kept secret of F#

Despite having been using F# as my go-to language for any personal project for 5+ years now, there are still simple things about the language that -- not being pointed out in the texts -- had passed me by until now. Prompted by a number of questions on the MSDN F# forum about porting some category theory implementation in ML to F#, I tried the exercise myself over a few evenings.

To my surprise, almost everything just ported over with mechanical syntax changes -- with the notable exception that F# doesn't have an infix keyword to mark a function as behaving like an operator. This included repeated idioms involving pattern matching in function arguments

even though you can't do multiple overloads of the same function name with different patterns, Erlang style (those would have to be different cases in a function expression); you can even have your destructuring and eat it too as in

where you have names for a component of the first argument and the first argument as a whole brought into scope. This generalises to being able to provide names for components of a tuple argument

you just have to parenthesise appropriately to distinguish taking the last element or the tuple as a whole.

There is one caveat -- if you want to do pure destructuring to assign names to components and write

this gets parsed as defining a function Cat on a tuple that returns a constant; unlike in SML you have to provide a dummy name for the whole expression

or parenthesise it, to get the destructuring assignment to id and comp that you wanted in the first place.

April foolery

Normally at this time of year, after the clocks have gone forwards, I think to myself that there's light in the evenings, but it's still too cold to do anything with it. This week it's been mild enough that I've sat out at the picnic table twice in the evening to eat my supper, as well as doing the necessary weeding.