Functional Programming & Proofs
Introduction (3): Tuples and Unions
- Union types (definitions) - eg. Options
type Result = Nothing | Value;;
Adding parameter:
type Result = Nothing | Value of float;;
let sqr (x:float) = if x<0 then Nothing else Value (sqrt x);;
sqr -2.0;;
Making type more generic
:
type Result<'a> = Nothing | Value of 'a;; // type 'a Result = ...
sqr 2.0;; // val it: Result<float> = Value 1.414213562
END 1
7 - 8
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide
docteur dr laurent thiry uha mulhouse france functional programming fsharp proof theory coq coqide