File: math-generic-measures.fs

package info (click to toggle)
fsharp 4.0.0.4%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,824 kB
  • ctags: 1,395
  • sloc: cs: 2,983; ml: 1,098; makefile: 410; sh: 409; xml: 113
file content (69 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#if COMPILED
module Core_genericMeasures
#else
module Core_genericMeasures =
#endif
    [<AllowNullLiteral>]
    type C<'T> = class end
    
    [<Measure>] type t
    let f1 (_ : int<t>) = ()
    let f2 (_ : float<t>) = ()
    let f3 (_ : int<_>) = ()
    let f4 (_ : float<_>) = ()
    let f5 (_ : C<'a>) = ()
    let f6 (_ : list<'a>) = ()
    
    let foo() =
        let a = 0<_>
        let b = 0.0<_>
        let c = null : C<int<_>>
        let d = null : C<float<_>>
        let e = [] : list<int<_>>
        let f = [] : list<float<_>>
        let g = null : C<int<_> * _>
        let h = null : C<_ * int<_> * _>
        let i : List<int<_>> = List.empty
        let j : List<float<_>> = List.empty
    
        f1 a
        f2 b
        f3 a
        f4 b
        f5 c
        f5 d
        f6 e
        f6 f
        f5 g
        f5 h
        f6 i
        f6 j
    
    type T = 
        static member Foo(_ : int<t>) = ()
        static member Foo1(_ : int<_>) = ()
    
        static member Bar() =
            let x = 0<_>
            T.Foo(x)
    
        static member Baz() =
            let x = 0<_>
            T.Foo1(x)
    
    let RunAll() = 
        foo()
        T.Bar()
        T.Baz()
    

#if ALL_IN_ONE
    let RUN() = RunAll(); []
#else
    RunAll();
    stdout.WriteLine "Test Passed"
    System.IO.File.WriteAllText("test.ok","ok")
    exit 0
#endif