{-@ LIQUID "--expect-any-error" @-}
module T1498 where

class FromTo a where 
  from :: a -> Int 
  to   :: Int -> a 

@ instance   where 
       from : : Int - > { v : Int | 0 < = v } ; 
       to    : : { v : Int | 0 < = v } - > Int 
 @
      from :: Int -> {v:Int | 0 <= v };
      to   :: {v:Int | 0 <= v } -> Int 
@-}

instance FromTo Int where 
  from x = x -- if 0 <= x then x else -x  
  to   x = x 


class A a where
  f :: a -> Int

{-@ instance A Int where
      f :: Int -> {x : Int | 0 < x}
  @-}
instance A Int where
  f n = (-1)

{-@ g :: Int -> {n : Int | 0 < n} @-}
g :: Int -> Int
g x = f x

@ LIQUID "--expect-any-error" @
 if 0 <= x then x else -x  
@ instance A Int where
      f :: Int -> {x : Int | 0 < x}
  @
@ g :: Int -> {n : Int | 0 < n} @
module T1498 where

class FromTo a where 
  from :: a -> Int 
  to   :: Int -> a 

@ instance   where 
       from : : Int - > { v : Int | 0 < = v } ; 
       to    : : { v : Int | 0 < = v } - > Int 
 @
      from :: Int -> {v:Int | 0 <= v };
      to   :: {v:Int | 0 <= v } -> Int 
@-}

instance FromTo Int where 
  to   x = x 


class A a where
  f :: a -> Int

instance A Int where
  f n = (-1)

g :: Int -> Int
g x = f x
