True
is a bad argument10
is a good argument0
average
take
fib
fib
is an uninterpreted functionBool> = Tagged (content :: a) @-} data Tagged a = Tagged a {-@ data variance Tagged covariant contravariant @-} instance Functor Tagged where fmap f (Tagged x) = Tagged (f x) instance Applicative Tagged where pure = Tagged -- f (a -> b) -> f a -> f b (Tagged f) <*> (Tagged x) = Tagged (f x) instance Monad Tagged where return x = Tagged x (Tagged x) >>= f = f x (Tagged _) >> t = t fail = error {-@ instance Monad Tagged where >>= :: forall
Bool, f:: a -> b -> Bool>. x:Tagged
a -> (u:a -> Tagged
(b (b Bool>. a -> Tagged a
@-}
{-@ liftM :: forall a b Bool, f:: a -> b -> Bool>.
x: Tagged a
-> (u:a -> b (b Bool, f:: a -> b -> Bool>.
-- (u:a -> b a
-- -> Tagged (b Bool>.
viewer:Tagged (User )
-> msg:Tagged String
-> IO () @-}
print = undefined
-- This is a bad type because p is at the same time co- anc contra- variant
-- so putting it on the result type creates inconsistencies.
{- getCurrentUser :: forall Bool>.
w:World -> Tagged (User ) @-}
{-@ measure currentUser :: World -> User @-}
{- getCurrentUser :: w:World -> Tagged {v:User | v == currentUser w }@-}
getCurrentUser :: Tagged User
getCurrentUser = undefined
{-@ whenUserIsChair ::forall Bool>. Tagged <{\v -> v == Chair}>[a] -> Tagged [a] @-}
whenUserIsChair :: Tagged [a] -> Tagged [a]
whenUserIsChair t = do
u <- getCurrentUser
if u == Chair then t else return []