Skip to content
Merged
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
12 changes: 9 additions & 3 deletions primer/src/Primer/Action/Available.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import Primer.Core (
_type,
_typeMetaLens,
)
import Primer.Core.Transform (decomposeTAppCon)
import Primer.Core.Utils (forgetTypeMetadata, freeVars)
import Primer.Def (
ASTDef (..),
Expand All @@ -104,7 +105,6 @@ import Primer.TypeDef (
TypeDefMap,
ValCon (valConArgs),
valConName,
valConType,
)
import Primer.Typecheck (
Cxt,
Expand Down Expand Up @@ -585,8 +585,14 @@ options typeDefs defs cxt level def0 sel0 = \case
ExprNode e
| Just t <- exprType e -> do
pure $
vcs <&> \vc@(vc', tc, td) ->
(globalOpt' (t `eqType` valConType tc td vc') (valConName vc'), vc)
vcs <&> \vc@(vc', tc, _) ->
-- Since all datatypes are regular ADTs (not GADTs), the only things needed for
-- a value constructor to be a correct fit for a hole are
-- - the hole's type is "a type constructor applied to a bunch of things"
-- - the hole's type is a satuarated application (this is guaranteed by
-- the program being well-typed, and that types of expressions are of kind KType)
-- - the head of the type (the type constructor) is the parent of the value constructor
(globalOpt' ((Just tc ==) $ fst <$> decomposeTAppCon t) (valConName vc'), vc)
_ ->
pure $ vcs <&> \vc@(vc', _, _) -> (globalOpt . valConName $ vc', vc)
exprType e = e ^? _exprMetaLens % _type % _Just % (_chkedAt `afailing` _synthed)
Expand Down