Types + Properties = Software

Sign in to queue

The Discussion

  • User profile image
    Tomas

    Hello there, the conf is just awesome!

    I like the data structures like this that does not allow to represent an illegal state. Is there a straightforward way to expose such data structure to C# code?

    What is more common/correct scenario? To force the C# user of the F# library to instantiate the F# data structure? Or to provide "standard" class and covert it to discriminated union internally in the library?

    Thank you for great talk!
    Tomas

  • User profile image
    Matt Freeman

    Great example, I wish I had heard about the tennis kata earlier, I think it's a perfect example to demonstrate benefits of f# or ocaml.

  • User profile image
    ploeh

    @Tomas: You easily can't translate this technique to C#, because it relies on discriminated unions to give you another axis of variability in how you statically express the value space of a type. This leads into what's called algebraic data types, Here's an easy-to-read introduction: http://tomasp.net/blog/types-and-math.aspx

    Discriminated unions are usable from C#, but a bit awkward. In order to harvest the full benefits of F#, it's best to stay within F#.

Add Your 2 Cents