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

Analysis effects #379

Merged
merged 271 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
271 commits
Select commit Hold shift + click to select a range
3aa3cb5
Define a concrete Env carrier.
robrix Nov 1, 2019
4f44170
Derive a MonadFail instance for EnvC.
robrix Nov 1, 2019
f0739bb
Run the env carrier.
robrix Nov 1, 2019
ec94b7d
Define a carrier for monovariant Env.
robrix Nov 1, 2019
131c804
Stub in a module for the Env effect.
robrix Nov 1, 2019
7809bd2
Move Env into its own module.
robrix Nov 1, 2019
6305e66
Run the env effect.
robrix Nov 1, 2019
d8955fd
Stub in a module for the precise Env carrier.
robrix Nov 1, 2019
06ea57e
Move the precise env carrier to its own module.
robrix Nov 1, 2019
e58db3d
Use the env effect in the concrete analysis.
robrix Nov 1, 2019
778f84b
Define a module for the monovariant Env carrier.
robrix Nov 1, 2019
5fef326
Move the monovariant Env carrier into its own module.
robrix Nov 1, 2019
9e472c5
Use the Env effect to define the Analysis.
robrix Nov 1, 2019
0f7be20
Use the Env effect to define the import graph analysis.
robrix Nov 1, 2019
eb591f9
Use the Env effect to define the scope graph analysis.
robrix Nov 1, 2019
6e1383d
Evaluate Core using the Env effect.
robrix Nov 1, 2019
d70a169
Reorder the contexts for ease of type application.
robrix Nov 4, 2019
17da79f
Reformat the importGraphAnalysis signature.
robrix Nov 4, 2019
961bf62
:fire: the Analysis env fields.
robrix Nov 4, 2019
6359d96
Stub in a module for the Heap effect.
robrix Nov 4, 2019
d23f34b
Move the Heap effect to its own module.
robrix Nov 4, 2019
b1c2f26
Define a smart constructor for Deref.
robrix Nov 4, 2019
ab5b566
Define a smart constructor for Assign.
robrix Nov 4, 2019
2502370
Section headings.
robrix Nov 4, 2019
e992998
Re-export Carrier & run from the effect modules.
robrix Nov 4, 2019
05de03e
Stub in a module for a precise heap carrier.
robrix Nov 4, 2019
b2a329c
Re-export the Heap effect.
robrix Nov 4, 2019
5b8364c
Stub in a Heap carrier.
robrix Nov 4, 2019
c3327fa
HeapC wraps a state effect.
robrix Nov 4, 2019
08e1061
Define a Carrier instance for Heap.
robrix Nov 4, 2019
aaa4f65
Stub in a module for a monovariant heap carrier.
robrix Nov 4, 2019
1b8dafc
Re-export the heap effect.
robrix Nov 4, 2019
a17a682
Define a monovariant Heap carrier.
robrix Nov 4, 2019
8f50312
Define a Carrier instance for HeapC.
robrix Nov 4, 2019
327208e
Surface the precise heap through a State effect.
robrix Nov 4, 2019
9327861
Use the precise heap carrier to implement the Concrete analysis.
robrix Nov 4, 2019
8127690
Only import the effect.
robrix Nov 4, 2019
ec53cd9
:fire: some redundant qualifiers.
robrix Nov 4, 2019
309b5fd
Export runNonDetM.
robrix Nov 4, 2019
6199c15
Run flow-insensitive analyses in an Alternative context.
robrix Nov 4, 2019
29d6654
Use the Heap effect in Typecheck.
robrix Nov 4, 2019
ca50eb2
Run the Heap effect inside convergeTerm.
robrix Nov 4, 2019
d5b180b
Revert "Run flow-insensitive analyses in an Alternative context."
robrix Nov 4, 2019
641b989
Revert "Export runNonDetM."
robrix Nov 4, 2019
42b7e77
Use the Heap effect to define the import graph analysis.
robrix Nov 4, 2019
3e987cc
Sort constraints.
robrix Nov 4, 2019
9303d7e
Use the Heap effect to define the scope graph analysis.
robrix Nov 4, 2019
07568e5
Use the Heap effect to define eval.
robrix Nov 4, 2019
a667c65
Reformat the signature for concreteAnalysis.
robrix Nov 4, 2019
a55972e
Remove the heap fields from Analysis.
robrix Nov 4, 2019
1098d95
Stub in a module for modelling the concrete domain.
robrix Nov 4, 2019
664c730
Stub in a Domain datatype modelling the basic kinds of values.
robrix Nov 4, 2019
d4190dd
Derive some instances for Domain.
robrix Nov 4, 2019
e4caca6
Add Record to Domain.
robrix Nov 4, 2019
3721ccb
Add Lam to Domain.
robrix Nov 4, 2019
a3e7d51
Fix a typo.
robrix Nov 4, 2019
40d3e5e
Rename Arr to :->.
robrix Nov 4, 2019
24f6159
Domain is scope-safe.
robrix Nov 4, 2019
7208186
Copy Name in from Core.Name.
robrix Nov 4, 2019
99a84e5
Specialize Domain to Name.
robrix Nov 4, 2019
20555fc
Lam’s name is in Maybe.
robrix Nov 4, 2019
722e405
Define a smart constructor for Unit.
robrix Nov 4, 2019
6b6581d
Define a smart constructor for Bool.
robrix Nov 4, 2019
c9161d5
Define a smart constructor for String.
robrix Nov 4, 2019
ca3bb15
Define a smart constructor for Record.
robrix Nov 4, 2019
9822b4e
Define a smart constructor for Lam.
robrix Nov 4, 2019
2d362d9
Define a smart constructor for multiple lambdas.
robrix Nov 4, 2019
3bafe21
Define an eliminator for Lam.
robrix Nov 4, 2019
e5bfa87
Derive Foldable, Functor, & Traversable instances for Domain.
robrix Nov 4, 2019
4b0af27
Rename Domain to Intro.
robrix Nov 4, 2019
a5e1d5e
Derive a Generic1 instance for Intro.
robrix Nov 4, 2019
2059137
Define an HFunctor instance for Intro.
robrix Nov 4, 2019
23d1c84
Define a RightModule instance for Intro.
robrix Nov 4, 2019
ea2b679
Export Name.
robrix Nov 4, 2019
4811add
Define a smart constructor for Lam binding with Fin.
robrix Nov 4, 2019
cd5165c
Strengthen to Fin without Var.
robrix Nov 4, 2019
95298aa
Avoid loading every package five times.
robrix Nov 5, 2019
9f26a4c
Stub in a module for Name.
robrix Nov 5, 2019
9672556
Move Name into its own module.
robrix Nov 5, 2019
0e69c0a
Use Analysis.Name in Core.
robrix Nov 5, 2019
98acd3a
Specialize concrete analysis to Name.
robrix Nov 5, 2019
924e0d0
:fire: Frame.
robrix Nov 5, 2019
29b1170
Move Edge down.
robrix Nov 5, 2019
398d377
Specialize Concrete to Name.
robrix Nov 5, 2019
2f676e8
Specialize the Env synonym to Name.
robrix Nov 5, 2019
535ec05
:fire: some quantifiers.
robrix Nov 5, 2019
71e4981
Specialize EdgeType to Name.
robrix Nov 5, 2019
50e123a
Specialize the typechecking analysis to Name.
robrix Nov 5, 2019
814f6fe
:fire: quantifiers.
robrix Nov 5, 2019
18bc19a
Specialize Type, Constraint, Solution, & Substitution to Name.
robrix Nov 5, 2019
630759d
Specialize Monotype to Name.
robrix Nov 5, 2019
a3775a1
Specialize the import graph analysis to Name.
robrix Nov 5, 2019
4962104
Specialize Value to Name.
robrix Nov 5, 2019
6191f2e
Specialize the scope graph analysis to Name.
robrix Nov 5, 2019
611ae5f
:fire: quantifiers.
robrix Nov 5, 2019
f03de00
:fire: ScopedTypeVariables.
robrix Nov 5, 2019
d06d73c
Rename a bunch of type parameters.
robrix Nov 5, 2019
b33c694
Sort constraints.
robrix Nov 5, 2019
1b61ce5
Sort explicit quantifiers.
robrix Nov 5, 2019
e9b6658
Specialize flow-insensitive caching to Name addresses.
robrix Nov 5, 2019
56b30e4
:fire: FrameId.
robrix Nov 5, 2019
f8c26e7
:fire: FrameId.
robrix Nov 5, 2019
02ae8de
Specialize Analysis to Name.
robrix Nov 5, 2019
23c65d5
Specialize Domain to Name.
robrix Nov 5, 2019
7f6680d
Specialize the Env effect to Name.
robrix Nov 5, 2019
daa24d1
:fire: a redundant handler.
robrix Nov 5, 2019
b4c4ddc
Simplify the sample .ghci file.
robrix Nov 5, 2019
f8b1b28
Move lamFin under unlam.
robrix Nov 6, 2019
14ff797
Define an eliminator for lambdas using Fin.
robrix Nov 6, 2019
ef44b29
Define a constructor for Lam using Var.
robrix Nov 6, 2019
812a123
Sort Name down.
robrix Nov 6, 2019
903e73c
Stub in a module for the Domain effect.
robrix Nov 6, 2019
374f90d
Re-export some stuff.
robrix Nov 6, 2019
e8a4749
Stub in a Domain effect with abstraction & concretization operations.
robrix Nov 6, 2019
7b9e1c0
Derive a Generic1 instance for Domain.
robrix Nov 6, 2019
6e1503c
Define an HFunctor instance for Domain.
robrix Nov 6, 2019
180af3f
Define an Effect instance for Domain.
robrix Nov 6, 2019
d4a1080
Align.
robrix Nov 6, 2019
0dd17dc
Define a smart constructor for abstracting domain values.
robrix Nov 6, 2019
34f3297
Define a smart constructor for concretization.
robrix Nov 6, 2019
445737a
:fire: the old Domain effect.
robrix Nov 6, 2019
fd19464
Rename the parameters to Domain.
robrix Nov 6, 2019
4a0aa12
Spacing.
robrix Nov 6, 2019
4185f21
Remove everything but the primitives from Intro.
robrix Nov 7, 2019
27559f8
Specialize the Domain effect to Intro.
robrix Nov 7, 2019
56cc4e1
Construct Unit, Bool, & String via the Domain effect.
robrix Nov 7, 2019
4ede4ae
Concretize values via the Domain effect.
robrix Nov 7, 2019
ee8017d
Define a Domain carrier for typechecking.
robrix Nov 7, 2019
38e42c0
Align.
robrix Nov 7, 2019
9918460
Run the domain effect during convergence.
robrix Nov 7, 2019
da11239
Merge branch 'master' into analysis-effects
robrix Dec 2, 2019
34a0afb
Merge branch 'fused-effects-one-dot-zero' into analysis-effects
robrix Dec 12, 2019
a468a66
:fire: bool/asBool.
robrix Dec 13, 2019
9a3e06b
Define smart constructors for unit, bool, & string construction.
robrix Dec 13, 2019
d113cc4
Use the smart constructors to tidy up Core.Eval.
robrix Dec 13, 2019
a8d670c
Define smart constructors for concretization at specific types.
robrix Dec 13, 2019
fbd86f3
Concretize using the smart constructors.
robrix Dec 13, 2019
0fc9f5d
:fire: unit from Analysis.
robrix Dec 13, 2019
aac1c92
:fire: string/asString from Analysis.
robrix Dec 13, 2019
3ecb198
Build all the dependencies in the dist-repl dir.
robrix Dec 16, 2019
8cca0f1
Make sure fused-syntax gets loaded by ghcide.
robrix Dec 16, 2019
ff4523e
Extract the basic introduction forms into a new syntax type.
robrix Dec 16, 2019
667f894
Merge branch 'ghcide-is-painless' into analysis-effects
robrix Dec 18, 2019
6485f85
Move Named & Ignored into Analysis.Name.
robrix Dec 18, 2019
cfc8bdf
:fire: Ignored.
robrix Dec 18, 2019
63427b9
Alignment.
robrix Dec 18, 2019
443b4ca
Add lambdas to Intro.
robrix Dec 18, 2019
f85c31c
Merge branch 'master' into analysis-effects
robrix Dec 19, 2019
1d292b0
Parameterize terms by addresses.
robrix Dec 19, 2019
a60380a
Revert "Parameterize terms by addresses."
robrix Dec 19, 2019
1832212
Interpret functions using the Domain effect.
robrix Dec 19, 2019
9f2a2fc
Define a smart constructor for constructing lambdas.
robrix Dec 19, 2019
039148a
Define a smart constructor for concretizing lambdas.
robrix Dec 19, 2019
a3ccc12
:fire: abstract & apply from Analysis.
robrix Dec 19, 2019
1bc3c65
:fire: the term parameter from Analysis.
robrix Dec 19, 2019
e546950
Parameterize terms by addresses.
robrix Dec 19, 2019
cb2a995
Add records to Intro.
robrix Dec 19, 2019
76c56e3
Concretize records.
robrix Dec 19, 2019
6810624
Note a fixme.
robrix Dec 19, 2019
c4db1c9
Evaluate records using the Domain effect.
robrix Dec 19, 2019
f68bce1
Reference variables using the Domain effect.
robrix Dec 19, 2019
cc403af
:fire: Analysis.
robrix Dec 19, 2019
4485d36
:fire: Evaluator.
robrix Dec 19, 2019
fdb0f51
Define an Addr synonym for typechecking.
robrix Dec 19, 2019
d22039b
Rename the Precise synonym to Addr.
robrix Dec 19, 2019
f7c2c74
Take addressed terms in Concrete.
robrix Dec 19, 2019
e78cc7b
Define an Addr synonym for import graphing.
robrix Dec 19, 2019
c3b632f
Import graphing uses addressed terms.
robrix Dec 19, 2019
da63c0c
Define an Addr synonym for scope graphing.
robrix Dec 19, 2019
d93686e
Scope graphing takes addressed terms.
robrix Dec 19, 2019
585b05f
:fire: the name parameters from Decl & ScopeGraph.
robrix Dec 19, 2019
e518beb
Derive some instances for DomainC.
robrix Dec 19, 2019
de09619
Define a MonadTrans instance for DomainC.
robrix Dec 19, 2019
1f9e0fa
Reformat a context.
robrix Dec 19, 2019
387824a
Closure holds a Scope.
robrix Dec 19, 2019
a64c337
Graph the heap using the addresses in closure bodies.
robrix Dec 19, 2019
b013780
Define an Algebra instance for DomainC.
robrix Dec 19, 2019
8743374
Run the Domain effect for concrete analysis.
robrix Dec 19, 2019
875a408
Allow the evaluator to use the Domain effect.
robrix Dec 19, 2019
964d8e2
Allow the evaluator to use the heap & env effects.
robrix Dec 19, 2019
ac274cb
Combine the Has constraints.
robrix Dec 19, 2019
c707fe5
Strengthen the constraints available to typechecked evaluators.
robrix Dec 19, 2019
abd647e
Wrap closure bodies in Named.
robrix Dec 19, 2019
6e5cb7f
Semi closures wrap a scope.
robrix Dec 19, 2019
b007c9d
Define a Domain carrier.
robrix Dec 19, 2019
db5ef7b
Define a MonadTrans instance for DomainC.
robrix Dec 19, 2019
3be6999
Define an Algebra instance for DomainC.
robrix Dec 19, 2019
0f7188a
Run the Domain effect.
robrix Dec 19, 2019
fec21c7
Strengthen the constraints available to eval.
robrix Dec 19, 2019
17a6f02
Note a FIXME.
robrix Dec 19, 2019
3ff821b
Define a Domain carrier.
robrix Dec 19, 2019
3f23042
Derive some instances.
robrix Dec 19, 2019
1872847
Define a MonadTrans instance.
robrix Dec 19, 2019
3003f3f
Define a handler for Domain.
robrix Dec 19, 2019
bcb4eb9
Define an Algebra instance for DomainC.
robrix Dec 19, 2019
0f030b3
Note a FIXME.
robrix Dec 19, 2019
00e506c
Run the Domain effect.
robrix Dec 19, 2019
89d7bd5
Strengthen the constraints available to eval.
robrix Dec 19, 2019
f00affb
:fire: commented-out Analysis implementations.
robrix Dec 19, 2019
2e3713d
Represent import graphs’ semi-abstract values more discretely.
robrix Dec 19, 2019
26cf1d3
Revert "Represent import graphs’ semi-abstract values more discretely."
robrix Dec 19, 2019
2bbd2e0
Reformat the language extensions.
robrix Dec 19, 2019
3f43fb7
Apply stylish-haskell to Analysis.Effect.Domain.
robrix Dec 19, 2019
cd96cdb
Change the stylish-haskell config to format language pragmas vertical…
robrix Dec 19, 2019
582c71f
Reformat the language pragmas.
robrix Dec 19, 2019
37e5ba4
Split concretization into the primitive operations.
robrix Dec 20, 2019
c05904c
Note a couple of FIXMEs.
robrix Dec 20, 2019
59e5839
:fire: a redundant FIXME.
robrix Dec 20, 2019
624483b
Reformat the language pragmas in the Concrete analysis.
robrix Dec 20, 2019
53dda90
:fire: recordFrame.
robrix Dec 20, 2019
10386f7
Sort imports.
robrix Dec 20, 2019
7418fba
Reformat language pragmas.
robrix Dec 20, 2019
2052c70
Sort imports.
robrix Dec 20, 2019
580525a
Reformat language pragmas.
robrix Dec 20, 2019
38da7a4
Align cases locally.
robrix Dec 20, 2019
850811b
Reformat an import list.
robrix Dec 20, 2019
96f5204
Sort imports.
robrix Dec 20, 2019
a50ab43
Reformat language extensions.
robrix Dec 20, 2019
2fe68f3
Alignment.
robrix Dec 20, 2019
1948e2b
Sort/align imports.
robrix Dec 20, 2019
0860180
Reformat language pragmas.
robrix Dec 20, 2019
d876d01
Reformat language pragmas.
robrix Dec 20, 2019
1e1bd83
Reformat the Core destructors using LambdaCase.
robrix Dec 20, 2019
1828a1a
Use Analysis.Intro in Core’s syntax.
robrix Dec 20, 2019
58f6298
Revert "Use Analysis.Intro in Core’s syntax."
robrix Dec 20, 2019
5093315
Revert "Extract the basic introduction forms into a new syntax type."
robrix Dec 20, 2019
7c9c5f0
Declare the dependency on transformers.
robrix Dec 20, 2019
537f3c3
Move the cabal build call into script/repl.
robrix Dec 20, 2019
935fe94
Build the tests’ dependencies.
robrix Dec 20, 2019
a45de13
Build the benchmarks’ dependencies.
robrix Dec 20, 2019
c04c59d
Fix the semantic-python test build.
robrix Dec 20, 2019
3821557
Fix a couple of instances.
robrix Dec 20, 2019
f305c38
Add semantic-python’s tests to the load paths.
robrix Dec 20, 2019
8894d73
Correct a type signature.
robrix Dec 20, 2019
540b88c
Evaluate closed terms.
robrix Dec 20, 2019
bfec95a
Correct the package id for the sample .ghci.
robrix Dec 20, 2019
f78d90a
Remove the CHECK-JQ directive.
robrix Dec 20, 2019
f5efb6a
:fire: Analysis.ScopeGraph.
robrix Dec 20, 2019
75a63dd
Split up abstraction into separate constructors.
robrix Dec 20, 2019
6612273
Don’t repeat ourselves.
robrix Dec 20, 2019
c07324f
Split Domain into multiple effects.
robrix Dec 20, 2019
a167ded
Rename the abstract parameter to value.
robrix Dec 20, 2019
a6fe9b7
Alignment.
robrix Dec 20, 2019
1a67082
Simplify a pattern match.
robrix Dec 20, 2019
d278a01
Placate hlint.
robrix Jan 6, 2020
e34444e
Revert "Placate hlint."
robrix Jan 6, 2020
29e09be
Trick hlint.
robrix Jan 6, 2020
55e573e
Revert "Trick hlint."
robrix Jan 6, 2020
f5c8346
Ignore hints in assertEvaluatesTo.
robrix Jan 6, 2020
4022643
Don’t shout about the HLINT pragma.
robrix Jan 6, 2020
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
9 changes: 2 additions & 7 deletions .ghci.sample
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
-- Consider copying this to your ~/.ghc/ghci.conf file:

-- Pretty-printing
:set -ignore-package pretty-simple -package pretty-simple
:def! pretty \ _ -> pure ":set -interactive-print Text.Pretty.Simple.pPrint"
:def! no-pretty \ _ -> pure ":set -interactive-print System.IO.print"
:def! r \_ -> pure ":reload\n:pretty"
:set -package-id prtty-smpl-3.1.1.0-c89f0500
:set -interactive-print Text.Pretty.Simple.pPrint
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantic-ast depends on pretty-simple now, which makes it much more challenging to use -package pretty-simple in your ~/.ghci file since ghci “helpfully” ends up loading it twice.

You can avoid that issue by using -package-id, at the cost of having to keep that up to date whenever semantic gets an updated version of it.

I’m not happy with this, but I don’t know a better means of doing this aside from e.g. introducing a new registered package which nothing in semantic depends on just to re-export pretty-simple’s interface, or using a different pretty-printer in semantic than used in the REPL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes! We should probably submit a bug somewhere to somebody?


-- Turn on some language extensions you use a lot
:seti -XFlexibleContexts -XOverloadedStrings -XTypeApplications
Expand All @@ -26,6 +24,3 @@

-- Better typed holes
:set -funclutter-valid-hole-fits -fabstract-refinement-hole-fits -frefinement-level-hole-fits=2

-- Enable pretty-printing immediately
:pretty
4 changes: 2 additions & 2 deletions .stylish-haskell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ steps:
# `{-#LANGUAGE #-}'.
#
# Default: vertical.
style: compact
style: vertical

# Align affects alignment of closing pragma brackets.
#
Expand All @@ -183,7 +183,7 @@ steps:
# between actual import and closing bracket.
#
# Default: true
align: true
align: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formats LANGUAGE pragmas each on a new line, with the #-} markers unaligned (for diff minimality).

{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}


# stylish-haskell can detect redundancy of some language pragmas. If this
# is set to true, it will remove those redundant pragmas. Default: true.
Expand Down
4 changes: 1 addition & 3 deletions script/ghci-flags
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ ghc_version="$(ghc --numeric-version)"
# recent hie-bios requires us to output to the file at $HIE_BIOS_OUTPUT, but older builds & script/repl don’t set that var, so we default it to stdout
output_file="${HIE_BIOS_OUTPUT:-/dev/stdout}"

# do a build of dependencies up front to ensure they’re all available
cabal v2-build -v0 all --only-dependencies

Comment on lines -13 to -15
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn’t work out as well as I’d hoped—the silent build means that you can get ghcide and/or script/repl appearing to just hang while it deals with building dependencies.

I’ve moved this to script/repl and removed the -v0.

build_products_dir="dist-newstyle/build/x86_64-osx/ghc-$ghc_version/build-repl"

function flags {
Expand Down Expand Up @@ -43,6 +40,7 @@ function flags {
echo "-isemantic-java/src"
echo "-isemantic-json/src"
echo "-isemantic-python/src"
echo "-isemantic-python/test"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lets script/repl find the source files in semantic-python’s tests.

echo "-isemantic-ruby/src"
echo "-isemantic-tags/src"
echo "-iapp"
Expand Down
3 changes: 3 additions & 0 deletions script/repl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ set -e

cd "$(dirname "$0")/.."

# do a build of dependencies up front to ensure they’re all available
cabal v2-build all --enable-benchmarks --enable-tests --only-dependencies
Comment on lines +9 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to moving this back here and removing the -v0 (which silences all output), this now also ensures that the benchmarks’ & tests’ dependencies have been built before loading the repl.


# exec ghci with the appropriate flags, and without the $GHC_ENVIRONMENT variable interfering
cabal v2-exec env -- -u GHC_ENVIRONMENT ghci -ghci-script=.ghci.repl $(script/ghci-flags) -no-ignore-dot-ghci $@
12 changes: 10 additions & 2 deletions semantic-analysis/semantic-analysis.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ library
import: common
hs-source-dirs: src
exposed-modules:
Analysis.Analysis
Analysis.Carrier.Env.Monovariant
Analysis.Carrier.Env.Precise
Analysis.Carrier.Heap.Monovariant
Analysis.Carrier.Heap.Precise
Analysis.Concrete
Analysis.Effect.Domain
Analysis.Effect.Env
Analysis.Effect.Heap
Analysis.File
Analysis.FlowInsensitive
Analysis.ImportGraph
Analysis.ScopeGraph
Analysis.Intro
Analysis.Name
Analysis.Typecheck
Control.Carrier.Fail.WithLoc
build-depends:
Expand All @@ -62,3 +69,4 @@ library
, semantic-source ^>= 0
, terminal-size ^>= 0.3
, text ^>= 1.2.3.1
, transformers ^>= 0.5
26 changes: 0 additions & 26 deletions semantic-analysis/src/Analysis/Analysis.hs

This file was deleted.

22 changes: 22 additions & 0 deletions semantic-analysis/src/Analysis/Carrier/Env/Monovariant.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
module Analysis.Carrier.Env.Monovariant
( -- * Env carrier
EnvC(..)
-- * Env effect
, module Analysis.Effect.Env
) where

import Analysis.Effect.Env
import Analysis.Name
import Control.Algebra
import qualified Control.Monad.Fail as Fail

newtype EnvC m a = EnvC { runEnv :: m a }
deriving (Applicative, Functor, Monad, Fail.MonadFail)

instance Algebra sig m
=> Algebra (Env Name :+: sig) (EnvC m) where
alg (L (Alloc name k)) = k name
alg (L (Bind _ _ m k)) = m >>= k
alg (L (Lookup name k)) = k (Just name)
alg (R other) = EnvC (alg (handleCoercible other))
33 changes: 33 additions & 0 deletions semantic-analysis/src/Analysis/Carrier/Env/Precise.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
module Analysis.Carrier.Env.Precise
( -- * Env carrier
EnvC(..)
-- * Env effect
, A.alloc
, A.bind
, A.lookupEnv
, A.Env(..)
) where

import qualified Analysis.Effect.Env as A
import Analysis.Name
import Control.Algebra
import Control.Effect.Fresh
import Control.Effect.Reader
import qualified Control.Monad.Fail as Fail
import qualified Data.Map as Map

type Precise = Int
type Env = Map.Map Name Precise

newtype EnvC m a = EnvC { runEnv :: m a }
deriving (Applicative, Functor, Monad, Fail.MonadFail)

instance ( Has Fresh sig m
, Has (Reader Env) sig m
)
=> Algebra (A.Env Precise :+: sig) (EnvC m) where
alg (L (A.Alloc _ k)) = fresh >>= k
alg (L (A.Bind name addr m k)) = local (Map.insert name addr) m >>= k
alg (L (A.Lookup name k)) = asks (Map.lookup name) >>= k
alg (R other) = EnvC (alg (handleCoercible other))
31 changes: 31 additions & 0 deletions semantic-analysis/src/Analysis/Carrier/Heap/Monovariant.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
module Analysis.Carrier.Heap.Monovariant
( -- * Heap carrier
HeapC(..)
-- * Heap effect
, module Analysis.Effect.Heap
) where
Comment on lines +2 to +7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factoring this out means that the abstract analyses get to share a lot of code.


import Analysis.Effect.Heap
import Control.Applicative (Alternative)
import Control.Algebra
import Control.Effect.State
import Control.Monad ((>=>))
import qualified Control.Monad.Fail as Fail
import Data.List.NonEmpty (nonEmpty)
import qualified Data.Map as Map
import Data.Monoid (Alt(..))
import qualified Data.Set as Set

newtype HeapC addr value m a = HeapC { runHeap :: m a }
deriving (Alternative, Applicative, Functor, Monad, Fail.MonadFail)

instance ( Alternative m
, Has (State (Map.Map addr (Set.Set value))) sig m
, Ord addr
, Ord value
)
=> Algebra (Heap addr value :+: sig) (HeapC addr value m) where
alg (L (Deref addr k)) = gets (Map.lookup addr >=> nonEmpty . Set.toList) >>= maybe (pure Nothing) (getAlt . foldMap (Alt . pure . Just)) >>= k
alg (L (Assign addr value k)) = modify (Map.insertWith (<>) addr (Set.singleton value)) >> k
alg (R other) = HeapC (alg (handleCoercible other))
28 changes: 28 additions & 0 deletions semantic-analysis/src/Analysis/Carrier/Heap/Precise.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
module Analysis.Carrier.Heap.Precise
( -- * Heap carrier
runHeap
, HeapC(..)
-- * Heap effect
, module Analysis.Effect.Heap
) where

import Analysis.Effect.Heap
import Control.Algebra
import Control.Carrier.State.Strict
import qualified Control.Monad.Fail as Fail
import qualified Data.IntMap as IntMap

type Precise = Int

runHeap :: HeapC value m a -> m (IntMap.IntMap value, a)
runHeap (HeapC m) = runState mempty m

newtype HeapC value m a = HeapC (StateC (IntMap.IntMap value) m a)
deriving (Applicative, Functor, Monad, Fail.MonadFail)

instance (Algebra sig m, Effect sig)
=> Algebra (Heap Precise value :+: State (IntMap.IntMap value) :+: sig) (HeapC value m) where
alg (L (Deref addr k)) = HeapC (gets (IntMap.lookup addr)) >>= k
alg (L (Assign addr value k)) = HeapC (modify (IntMap.insert addr value)) >> k
alg (R other) = HeapC (alg (handleCoercible other))
Loading