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

chore: changes in preparation for hlint 3.6 #1092

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion primer/gen/Primer/Gen/Core/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ genSyns ty = do
Just . (APP () s aTy,) <$> substTy a aTy instTy
_ -> pure Nothing
genPrimCon' = do
genPrimCon <&> map (bimap (fmap $ PrimCon ()) (TCon ())) <&> filter (consistentTypes ty . snd) <&> \case
consistentCons <-
filter (consistentTypes ty . snd) . map (bimap (fmap $ PrimCon ()) (TCon ()))
<$> genPrimCon
pure $ case consistentCons of
Comment on lines 274 to +278
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes which I am less sure are improvements: 1/3

[] -> Nothing
gens -> Just $ Gen.choice $ (\(g, t) -> (,t) <$> g) <$> gens
genLet =
Expand Down
2 changes: 1 addition & 1 deletion primer/src/Primer/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ conInfo ::
m (Either Text (TC.Type, Int))
conInfo c =
asks (flip lookupConstructor c . TC.typeDefs) <&> \case
Just (vc, tc, td) -> Right (valConType tc td vc, length $ vc.valConArgs)
Just (vc, tc, td) -> Right (valConType tc td vc, length vc.valConArgs)
Nothing -> Left $ "Could not find constructor " <> show c

getTypeCache :: MonadError ActionError m => Expr -> m TypeCache
Expand Down
11 changes: 9 additions & 2 deletions primer/src/Primer/Action/Available.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import Data.Tuple.Extra (
uncurry3,
)
import Optics (
Field2 (_2),
afailing,
elemOf,
folded,
getting,
to,
view,
(%),
Expand Down Expand Up @@ -85,7 +89,7 @@ import Primer.Core (
_typeMetaLens,
)
import Primer.Core.Transform (decomposeTAppCon)
import Primer.Core.Utils (forgetTypeMetadata, freeVars, freeVarsTy)
import Primer.Core.Utils (forgetTypeMetadata, freeVars, _freeVarsTy)
import Primer.Def (
ASTDef (..),
DefMap,
Expand Down Expand Up @@ -385,7 +389,10 @@ forTypeDefParamNode paramName l Editable tydefs defs tdName td =
( l == Expert
&& not
( typeInUse tdName td tydefs defs
|| any (elem paramName . freeVarsTy) (concatMap valConArgs $ astTypeDefConstructors td)
|| elemOf
(to astTypeDefConstructors % folded % to valConArgs % folded % getting _freeVarsTy % _2)
paramName
td
)
Comment on lines 391 to 396
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes which I am less sure are improvements: 2/3

)
[NoInput DeleteTypeParam]
Expand Down
17 changes: 11 additions & 6 deletions primer/src/Primer/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import Optics (
ReversibleOptic (re),
elemOf,
folded,
getting,
ifoldMap,
mapped,
over,
Expand Down Expand Up @@ -171,7 +172,7 @@ import Primer.Core (
import Primer.Core.DSL (S, create, emptyHole, tEmptyHole)
import Primer.Core.DSL qualified as DSL
import Primer.Core.Transform (renameTyVar, renameVar, unfoldTApp)
import Primer.Core.Utils (freeVars, freeVarsTy, generateTypeIDs, regenerateExprIDs, regenerateTypeIDs, _freeTmVars, _freeTyVars, _freeVarsTy)
import Primer.Core.Utils (freeVars, generateTypeIDs, regenerateExprIDs, regenerateTypeIDs, _freeTmVars, _freeTyVars, _freeVarsTy)
import Primer.Def (
ASTDef (..),
Def (..),
Expand Down Expand Up @@ -799,8 +800,8 @@ applyProgAction prog = \case
traverseOf
#astTypeDefConstructors
( \cons -> do
when
(vcName `notElem` map valConName cons)
unless
(vcName `elem` map valConName cons)
(throwError $ ConNotFound vcName)
pure $ filter ((/= vcName) . valConName) cons
)
Expand Down Expand Up @@ -907,13 +908,17 @@ applyProgAction prog = \case
( \td -> do
checkTypeNotInUse tdName td $ m : ms
when
(any (elem paramName . freeVarsTy) $ concatMap valConArgs $ astTypeDefConstructors td)
( elemOf
(to astTypeDefConstructors % folded % to valConArgs % folded % getting _freeVarsTy % _2)
paramName
td
)
(throwError $ TypeParamInUse tdName paramName)
Comment on lines 910 to 916
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes which I am less sure are improvements: 3/3

traverseOf
#astTypeDefParameters
( \ps -> do
when
(paramName `notElem` map fst ps)
unless
(paramName `elem` map fst ps)
(throwError $ ParamNotFound paramName)
pure $ filter ((/= paramName) . fst) ps
)
Expand Down
2 changes: 1 addition & 1 deletion primer/src/Primer/TypeDef.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ data ValCon b = ValCon
valConType :: TyConName -> ASTTypeDef () -> ValCon () -> Type' ()
valConType tc td vc =
let ret = mkTAppCon tc (TVar () . fst <$> astTypeDefParameters td)
args = foldr (TFun ()) ret (forgetTypeMetadata <$> valConArgs vc)
args = foldr (TFun () . forgetTypeMetadata) ret (valConArgs vc)
foralls = foldr (\(n, k) t -> TForall () n k t) args (astTypeDefParameters td)
in foralls

Expand Down
2 changes: 1 addition & 1 deletion primer/src/Primer/Zipper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ focusOn' i = fmap snd . search matchesID
-- If the target has an embedded type, search the type for a match.
-- If the target is a case expression with bindings, search each binding for a match.
| otherwise =
let inType = focusType z >>= search (guarded (== i) . getID . target) <&> fst <&> InType
let inType = focusType z >>= search (guarded (== i) . getID . target) <&> InType . fst
inCaseBinds = findInCaseBinds i z
in inType <|> inCaseBinds

Expand Down