Skip to content

Commit

Permalink
Allow LH to understand integer literals using GHC.Num.Integer.IS
Browse files Browse the repository at this point in the history
Fixes #2237
  • Loading branch information
facundominguez committed Nov 17, 2023
1 parent 2a97f15 commit f2f63f9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions liquidhaskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ library
GHC.IO.Handle_LHAssumptions
GHC.List_LHAssumptions
GHC.Num_LHAssumptions
GHC.Num.Integer_LHAssumptions
GHC.Maybe_LHAssumptions
GHC.Ptr_LHAssumptions
GHC.Real_LHAssumptions
Expand All @@ -80,6 +81,7 @@ library
liquidhaskell-boot == 0.9.2.8.0,
bytestring == 0.11.4.0,
containers == 0.6.5.1,
ghc-bignum,
ghc-prim
default-language: Haskell98
ghc-options: -Wall -fplugin=LiquidHaskellBoot
Expand Down
12 changes: 12 additions & 0 deletions src/GHC/Num/Integer_LHAssumptions.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{-# LANGUAGE MagicHash #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
module GHC.Num.Integer_LHAssumptions() where

import GHC.Types
import GHC.Num.Integer
import GHC.Types_LHAssumptions()


{-@
assume GHC.Num.Integer.IS :: x:GHC.Prim.Int# -> {v: GHC.Num.Integer | v = (x :: int) }
@-}
12 changes: 12 additions & 0 deletions tests/pos/T2237.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{-# LANGUAGE MagicHash #-}
-- | Tests that LH can reason with literals using the IS data constructor
module T2237 () where

import Language.Haskell.Liquid.Prelude (liquidError, liquidAssertB)
import qualified GHC.Num.Integer

data Foo a = F a

{-@ flibInt :: (Num a, Ord a) => a -> Bool @-}
flibInt x = prop1 x (F (x + fromInteger (GHC.Num.Integer.IS 1#)))
prop1 x (F y) = liquidAssertB (x < y)
1 change: 1 addition & 0 deletions tests/tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,7 @@ executable unit-pos-1
, T2093
, T2096
, T2235
, T2237
, T385
, T531
, T595a
Expand Down

0 comments on commit f2f63f9

Please sign in to comment.