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

Update typecheck command to check for coverage #1952

Merged
merged 1 commit into from
Mar 30, 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
7 changes: 4 additions & 3 deletions app/Commands/Typecheck.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module Commands.Typecheck where

import Commands.Base
import Commands.Dev.Internal.Typecheck qualified as Internal
import Commands.Typecheck.Options

runCommand :: (Members '[Embed IO, App] r) => TypecheckOptions -> Sem r ()
runCommand = Internal.runCommand . project
runCommand :: Members '[Embed IO, App] r => TypecheckOptions -> Sem r ()
runCommand localOpts = do
void (runPipeline (localOpts ^. typecheckInputFile) upToCoreTypecheck)
say "Well done! It type checks"
3 changes: 3 additions & 0 deletions src/Juvix/Compiler/Core/Data/TransformationId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ fromTransformationLike = \case
fromTransformationLikes :: [TransformationLikeId] -> [TransformationId]
fromTransformationLikes = concatMap fromTransformationLike

toTypecheckTransformations :: [TransformationId]
toTypecheckTransformations = [MatchToCase]

toEvalTransformations :: [TransformationId]
toEvalTransformations = [EtaExpandApps, MatchToCase, NatToInt, ConvertBuiltinTypes, LetFolding]

Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Compiler/Core/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import Juvix.Compiler.Pipeline.EntryPoint (EntryPoint)
toEval' :: Members '[Error JuvixError, Reader CoreOptions] r => InfoTable -> Sem r InfoTable
toEval' = applyTransformations toEvalTransformations

toTypechecked :: Members '[Error JuvixError, Reader EntryPoint] r => InfoTable -> Sem r InfoTable
toTypechecked = mapReader fromEntryPoint . applyTransformations toTypecheckTransformations

toEval :: Members '[Error JuvixError, Reader EntryPoint] r => InfoTable -> Sem r InfoTable
toEval = mapReader fromEntryPoint . applyTransformations toEvalTransformations

Expand Down
6 changes: 6 additions & 0 deletions src/Juvix/Compiler/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ upToGeb ::
upToGeb spec =
upToCore >>= \Core.CoreResult {..} -> coreToGeb spec _coreResultTable

upToCoreTypecheck ::
(Members '[Reader EntryPoint, Files, NameIdGen, Error JuvixError, Builtins, PathResolver] r) =>
Sem r Core.CoreResult
upToCoreTypecheck =
upToCore >>= \r -> Core.toTypechecked (r ^. Core.coreResultTable) >>= \tab -> return r {Core._coreResultTable = tab}

upToEval ::
(Members '[Reader EntryPoint, Files, NameIdGen, Error JuvixError, Builtins, PathResolver] r) =>
Sem r Core.CoreResult
Expand Down