mirror of
https://github.com/Smaug123/fsharp-vectors
synced 2025-10-10 05:38:39 +00:00
Tidy up
This commit is contained in:
24
Vector/Arithmetic.fs
Normal file
24
Vector/Arithmetic.fs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Vector.Naturals
|
||||
|
||||
/// Zero, in the Peano encoding of the naturals
|
||||
type Z =
|
||||
private
|
||||
| Z
|
||||
|
||||
/// Successor, in the Peano encoding of the naturals
|
||||
type S<'a> =
|
||||
private
|
||||
| S
|
||||
// Computation rules
|
||||
static member inline refine< ^n1, ^n2 when ^n1 : (static member refine : ^n1 -> ^n2)> (_ : S<'n1>) : S<'n2> = Unchecked.defaultof<_>
|
||||
|
||||
/// Type representing the sum of two naturals
|
||||
type Add<'a, 'b> =
|
||||
private
|
||||
| Add
|
||||
// Computation rules
|
||||
static member inline refine (_ : Add<Z, Z>) : Z = Unchecked.defaultof<_>
|
||||
static member inline refine< ^n1, ^n2> (_ : Add< S< ^n1>, S< ^n2>>) : S<S<Add< ^n1, ^n2>>> = Unchecked.defaultof<_>
|
||||
static member inline refine< ^n1, ^n2> (_ : Add< Z, ^n1>) : ^n2 = Unchecked.defaultof<_>
|
||||
static member inline refine< ^n1, ^n2 > (_ : Add< ^n1, Z>) : ^n2 = Unchecked.defaultof<_>
|
||||
|
Reference in New Issue
Block a user