1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-14 08:27:03 +03:00
juvix/app/Commands/Dev/Termination/CallGraph.hs
Jonathan Cubides 807b3b1770
Update CI to install Smoke, Github actions, and Makefile fixes (#1735)
This PR adds some maintenance at different levels to the CI config, the
Make file, and formatting.

- Most of the actions used by the CI related to haskell, ormolu, hlint
and pre-commit have been updated because Github requires NodeJS 16. This
change removes all the old warnings related to nodeJs.
In the case of ormolu, the new version makes us format some files that
were not formatted before, similarly with hlint.
- The CI has been updated to use the latest version of the Smoke testing
framework, which introduced installation of the dependencies for Linux
(libicu66) and macOS (icu4c) in the CI. In the case of macOS, the CI
uses a binary for smoke. For Linux, we use stack to build smoke from the
source. The source here is in a fork of [the official Smoke
repo](https://github.com/SamirTalwar/smoke). Such includes some
features/changes that are not yet in the official repo.

- The Makefile runs the ormolu and hlint targets using as a path for the
binaries the environment variables ORMOLU and HLINT. Thus, export those
variables in your environment before running `make check,` `make format`
or `make hlint`. Otherwise, the Makefile will use the binaries provided
by `stack`.

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-01-24 11:50:23 +01:00

52 lines
2.2 KiB
Haskell

module Commands.Dev.Termination.CallGraph where
import Commands.Base
import Commands.Dev.Termination.CallGraph.Options
import Data.HashMap.Strict qualified as HashMap
import Juvix.Compiler.Abstract.Language qualified as Abstract
import Juvix.Compiler.Abstract.Pretty qualified as Abstract
import Juvix.Compiler.Abstract.Translation.FromConcrete qualified as Abstract
import Juvix.Compiler.Internal.Translation.FromAbstract.Analysis.Termination qualified as Termination
import Juvix.Prelude.Pretty
runCommand :: (Members '[Embed IO, App] r) => CallGraphOptions -> Sem r ()
runCommand CallGraphOptions {..} = do
globalOpts <- askGlobalOptions
results <- runPipeline _graphInputFile upToAbstract
let topModule = head (results ^. Abstract.resultModules)
toAnsiText' :: forall a. (HasAnsiBackend a, HasTextBackend a) => a -> Text
toAnsiText' = toAnsiText (not (globalOpts ^. globalNoColors))
infotable = results ^. Abstract.resultTable
callMap = Termination.buildCallMap infotable topModule
completeGraph = Termination.completeCallGraph callMap
filteredGraph =
maybe
completeGraph
(`Termination.unsafeFilterGraph` completeGraph)
_graphFunctionNameFilter
rEdges = Termination.reflexiveEdges filteredGraph
recBehav = map Termination.recursiveBehaviour rEdges
renderStdOut (Abstract.ppOut globalOpts filteredGraph)
newline
forM_ recBehav $ \r -> do
let funName = r ^. Termination.recursiveBehaviourFun
funRef = Abstract.FunctionRef funName
funInfo =
HashMap.lookupDefault
impossible
funRef
(infotable ^. Abstract.infoFunctions)
markedTerminating = funInfo ^. (Abstract.functionInfoDef . Abstract.funDefTerminating)
n = toAnsiText' (Abstract.ppOut globalOpts funName)
renderStdOut (Abstract.ppOut globalOpts r)
newline
if
| markedTerminating ->
printSuccessExit (n <> " Terminates by assumption")
| otherwise ->
case Termination.findOrder r of
Nothing ->
printFailureExit (n <> " Fails the termination checking")
Just (Termination.LexOrder k) ->
printSuccessExit (n <> " Terminates with order " <> show (toList k))