Skip to content

Instantly share code, notes, and snippets.

@pizycki
Last active July 18, 2019 19:55
Show Gist options
  • Select an option

  • Save pizycki/82402ae252a2695cb25469aa1b6591fa to your computer and use it in GitHub Desktop.

Select an option

Save pizycki/82402ae252a2695cb25469aa1b6591fa to your computer and use it in GitHub Desktop.
Unwrap value from DU in F#
// Based on https://stackoverflow.com/a/24293478/864968
type ReleaseRequestMovieTitle = ReleaseRequestMovieTitle of string
with
override this.ToString() =
this |> function
| ReleaseRequestMovieTitle x -> x
let x = (ReleaseRequestMovieTitle "bla");;
// val x : ReleaseRequestMovieTitle = ReleaseRequestMovieTitle "bla"
x.ToString();;
// val it : string = "bla"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment