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

Fix for #1906: adding GADT fields syntax #1922

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix for #1904 autolifting of data fields
  • Loading branch information
Fizzixnerd committed Jan 6, 2022
commit 9f2076b127807c2fbc67441b6430be2ba77233e3
12 changes: 8 additions & 4 deletions src/Language/Haskell/Liquid/Bare/DataType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ makeDataConChecker = F.testSymbol . F.symbol
-- equivalent to `head` and `tail`.
--------------------------------------------------------------------------------
makeDataConSelector :: Maybe Bare.DataConMap -> Ghc.DataCon -> Int -> F.Symbol
makeDataConSelector dmMb d i = M.lookupDefault def (F.symbol d, i) dm
where
dm = Mb.fromMaybe M.empty dmMb
makeDataConSelector dmMb d i
| Just ithField <- ithFieldMb = F.symbol (Ghc.flSelector ithField)
| otherwise = M.lookupDefault def (F.symbol d, i) dm
where
fields = Ghc.dataConFieldLabels d
ithFieldMb = Misc.getNth (i - 1) fields
dm = Mb.fromMaybe M.empty dmMb
def = makeDataConSelector' d i


makeDataConSelector' :: Ghc.DataCon -> Int -> F.Symbol
makeDataConSelector' d i
Expand Down
12 changes: 12 additions & 0 deletions tests/datacon/pos/AutoliftedFields.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{-@ LIQUID "--exact-data-cons" @-}

module AutoliftedFields where

{-@ type Nat = { v : Int | v >= 0 } @-}
type Nat = Int

data T = T { getT :: Nat }

{-@ f :: { t : T | getT t >= 1 } -> Nat @-}
f :: T -> Nat
f (T x) = x