Skip to content

Commit

Permalink
Add scaffolfing for backtick imports
Browse files Browse the repository at this point in the history
  • Loading branch information
yav committed Dec 12, 2022
1 parent b35170a commit f834e24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Cryptol/ModuleSystem/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ findDeps' m =
DefaultInstArg a -> loadInstArg a
DefaultInstAnonArg ds -> mconcat (map depsOfDecl ds)
NamedInstArgs args -> mconcat (map loadNamedInstArg args)
BacktickInstnace -> mempty
in fds <> ads
InterfaceModule s -> mconcat (map loadImpD (sigImports s))
where
Expand Down
3 changes: 3 additions & 0 deletions src/Cryptol/ModuleSystem/Renamer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ checkFunctorArgs args =
panic "checkFunctorArgs" ["Nested DefaultInstAnonArg"]
DefaultInstArg l -> checkArg l
NamedInstArgs as -> mapM_ checkNamedArg as
BacktickInstnace -> pure ()
where
checkNamedArg (ModuleInstanceNamedArg _ l) = checkArg l

Expand Down Expand Up @@ -480,6 +481,7 @@ renameTopDecls' ds =
DefaultInstArg arg -> depsOfArg arg
NamedInstArgs args -> concatMap depsOfNamedArg args
DefaultInstAnonArg {} -> []
BacktickInstnace -> []

where depsOfNamedArg (ModuleInstanceNamedArg _ a) = depsOfArg a
depsOfArg a = case thing a of
Expand Down Expand Up @@ -793,6 +795,7 @@ instance Rename ModuleInstanceArgs where
DefaultInstArg a -> DefaultInstArg <$> rnLocated rename a
NamedInstArgs xs -> NamedInstArgs <$> traverse rename xs
DefaultInstAnonArg {} -> panic "rename" ["DefaultInstAnonArg"]
BacktickInstnace -> pure BacktickInstnace

instance Rename ModuleInstanceNamedArg where
rename (ModuleInstanceNamedArg x m) =
Expand Down
6 changes: 6 additions & 0 deletions src/Cryptol/Parser/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ data ModuleInstanceArgs name =
-- (parser only)

| NamedInstArgs [ModuleInstanceNamedArg name]

| BacktickInstnace
-- ^ The module instance is computed by adding the functor arguments
-- as explicit parameters to all declarations
deriving (Show, Generic, NFData)

-- | A named argument in a functor instantiation
Expand Down Expand Up @@ -863,6 +867,7 @@ instance (Show name, PPName name) => PP (ModuleInstanceArgs name) where
DefaultInstArg x -> braces (pp (thing x))
DefaultInstAnonArg ds -> "where" $$ indent 2 (vcat (map pp ds))
NamedInstArgs xs -> braces (commaSep (map pp xs))
BacktickInstnace -> "{}"

instance (Show name, PPName name) => PP (ModuleInstanceNamedArg name) where
ppPrec _ (ModuleInstanceNamedArg x y) = pp (thing x) <+> "=" <+> pp (thing y)
Expand Down Expand Up @@ -1358,6 +1363,7 @@ instance NoPos (ModuleInstanceArgs name) where
DefaultInstArg a -> DefaultInstArg (noPos a)
DefaultInstAnonArg ds -> DefaultInstAnonArg (noPos ds)
NamedInstArgs xs -> NamedInstArgs (noPos xs)
BacktickInstnace -> BacktickInstnace

instance NoPos (ModuleInstanceNamedArg name) where
noPos (ModuleInstanceNamedArg x y) =
Expand Down

0 comments on commit f834e24

Please sign in to comment.