Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection of functions with class constraints may produce unsound results #2443

Open
kleinreact opened this issue Nov 19, 2024 · 0 comments

Comments

@kleinreact
Copy link

kleinreact commented Nov 19, 2024

As already discussed on the LH Slack, the following example is reported to be safe although it isn't (tested with 8c550df).

{-@ LIQUID "" @-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fplugin=LiquidHaskell #-}

module T2443 where

import Data.Proxy

class C a where
  classConst :: Proxy a -> Int

instance C Int  where classConst _ = 0
instance C Bool where classConst _ = 1

{-@ reflect classConstR @-}
classConstR :: forall a. C a => a -> Int
classConstR _ = classConst (Proxy :: Proxy a)

{-@ cEq :: a -> b -> { b : Bool | b == True } @-}
cEq :: forall a b. (C a, C b) => a -> b -> Bool
cEq a b = classConstR a == classConstR b

{-@ trueEqualsFive :: { b : Bool | b == True } @-}
trueEqualsFive :: Bool
trueEqualsFive = cEq True (5 :: Int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant