Skip to content

Commit

Permalink
Using State Monad in GHC Core Translation (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillHallahan authored Oct 8, 2023
1 parent 5a29b69 commit 978fef2
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 251 deletions.
3 changes: 3 additions & 0 deletions g2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ library
, text-builder >= 0.6.6.1
, time >= 1.6 && <= 1.13
, unordered-containers >= 0.2.10.0 && < 0.3

-- remove this eventually
, deferred-folds <= 0.9.18.3

if flag(support-lh) && impl(ghc < 9.2)
build-depends: liquidhaskell >= 0.8.10.2 && <= 0.9.0.2.1
Expand Down
2 changes: 1 addition & 1 deletion src/G2/Initialization/KnownValues.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ superClassExtractor tc tc_n sc_n =
case lookupTCClass tc_n tc of
Just c
| Just (_, i) <- find extractsSC (superclasses c) -> idName i
| otherwise -> error $ "superClassExtractor: Extractor not found " ++ show (superclasses c)
| otherwise -> error $ "superClassExtractor: Extractor not found\n" ++ show sc_n ++ "\n" ++ show (superclasses c)
Nothing -> error $ "superClassExtractor: Class not found " ++ show tc_n
where
extractsSC (t, _) =
Expand Down
2 changes: 1 addition & 1 deletion src/G2/Language/TypeClasses/TypeClasses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ initTypeClasses nsi =
ns = map (\(n, _, i, sc) -> (n, i, sc)) nsi
nsi' = filter (not . null . insts . snd)
$ map (\(n, i, sc) ->
(n, Class { insts = mapMaybe (nameIdToTypeId n) nsi
(n, Class { insts = nub $ mapMaybe (nameIdToTypeId n) nsi
, typ_ids = i
, superclasses = sc } )) ns
in
Expand Down
2 changes: 1 addition & 1 deletion src/G2/Liquid/Conversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ rTyConType :: RTyCon -> [SpecType]-> LHStateM (Maybe Type)
rTyConType rtc sts = do
tenv <- typeEnv

let tcn = mkTyConName HM.empty . rtc_tc $ rtc
let tcn = mkTyConNameUnsafe . rtc_tc $ rtc
n = nameModMatch tcn tenv

ts <- mapM specTypeToType sts
Expand Down
2 changes: 1 addition & 1 deletion src/G2/Liquid/Measures.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ convertDefs :: [Type] -> Maybe Type -> LHDictMap -> BoundTypes -> Def SpecType G
convertDefs [l_t] ret m bt (Def { ctor = dc, body = b, binds = bds})
| TyCon _ _ <- tyAppCenter l_t
, st_t <- tyAppArgs l_t
, dc' <- mkData HM.empty HM.empty dc = do
, dc' <- mkDataUnsafe dc = do
tenv <- typeEnv
let
-- See [1] below, we only evaluate this if Just
Expand Down
Loading

0 comments on commit 978fef2

Please sign in to comment.