forked from ucsd-progsys/liquidhaskell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Variance.hs
47 lines (18 loc) · 1000 Bytes
/
Variance.hs
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
module Variance where
{-@ data variance Foo invariant bivariant covariant contravariant @-}
data Foo a b c d
{-@ check_covariant :: Foo a b {v:Int | v = 1} c -> Foo a b {v:Int | v > 0} c @-}
check_covariant :: Foo a b Int c -> Foo a b Int c
check_covariant r = r
{-@ check_contravariant0 :: Foo a b c {v:Int | v > 0} -> Foo a b c {v:Int | v = 1} @-}
check_contravariant0 :: Foo a b c Int-> Foo a b c Int
check_contravariant0 r = r
{-@ check_contravariant :: ((Foo a b c {v:Int | v = 1}) -> ()) -> (Foo a b c {v:Int | v > 0}) -> () @-}
check_contravariant :: ((Foo a b c Int) -> ()) -> Foo a b c Int -> ()
check_contravariant r = r
{-@ check_bivariant :: Foo a {v: Int | v = 1} c d -> Foo a {v:Int | ((v > 0) && (v < 2))} c d @-}
check_bivariant :: Foo a Int c d -> Foo a Int c d
check_bivariant r = r
{-@ check_invariant :: Foo {v: Int | v = 1} b c d -> Foo {v:Int | ((v > 0) && (v < 2))} b c d @-}
check_invariant :: Foo Int b c d -> Foo Int b c d
check_invariant r = r