Skip to content

Commit

Permalink
update typecheck command to check for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Mar 30, 2023
1 parent 9e9a884 commit 46c53b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
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

0 comments on commit 46c53b4

Please sign in to comment.