News for hackers. Stuff that matters.
Re:Computational Types in C# and F# by MichaelGG on Wednesday August 01, 2012 @02:27PM (#4324724)
The F# code isn't as slick as it should be. This is much better:

  type FullName = FullName of string
This is a sum type (discriminated union) with a single case. If you want to have a simple accessor just add:

  with member x.Value = match x with FullName x -> x
I'm not sure why you'd create all those records; it seems very messy.

Edit: Also, phantom types may be of interest. Here's an example in F#: http://stackoverflow.com/questions/3583679/implementing-phan...

There are no comments on this comment yet.