Merge remote-tracking branch 'origin/master' into semantic-scope-graph · github/semantic@3345967 · GitHub
Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 3345967

Browse files
author
Patrick Thomson
committed
Merge remote-tracking branch 'origin/master' into semantic-scope-graph
2 parents 760c52e + 5277a39 commit 3345967

39 files changed

Lines changed: 1073 additions & 775 deletions

File tree

.ghci.sample

Lines changed: 2 additions & 7 deletions

.github/workflows/haskell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
5454
- name: hlint
5555
run: |
56-
cabal install hlint --installdir=dist-newstyle
56+
test -f dist-newstyle/hlint || cabal install hlint --installdir=dist-newstyle
5757
dist-newstyle/hlint src semantic-python
5858
5959
- name: Build & test

.stylish-haskell.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ steps:
183183
# between actual import and closing bracket.
184184
#
185185
# Default: true
186-
align: true
186+
align: false
187187

188188
# stylish-haskell can detect redundancy of some language pragmas. If this
189189
# is set to true, it will remove those redundant pragmas. Default: true.

script/ghci-flags

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ ghc_version="$(ghc --numeric-version)"
1010
# 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
1111
output_file="${HIE_BIOS_OUTPUT:-/dev/stdout}"
1212

13-
# do a build of dependencies up front to ensure they’re all available
14-
cabal v2-build -v0 all --only-dependencies
15-
1613
build_products_dir="dist-newstyle/build/x86_64-osx/ghc-$ghc_version/build-repl"
1714

1815
function flags {
@@ -45,6 +42,7 @@ function flags {
4542
echo "-isemantic-java/src"
4643
echo "-isemantic-json/src"
4744
echo "-isemantic-python/src"
45+
echo "-isemantic-python/test"
4846
echo "-isemantic-ruby/src"
4947
echo "-isemantic-tsx/src"
5048
echo "-isemantic-typescript/src"

script/repl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ set -e
66

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

9+
# do a build of dependencies up front to ensure they’re all available
10+
cabal v2-build all --enable-benchmarks --enable-tests --only-dependencies
11+
912
# exec ghci with the appropriate flags, and without the $GHC_ENVIRONMENT variable interfering
1013
cabal v2-exec env -- -u GHC_ENVIRONMENT ghci -ghci-script=.ghci.repl $(script/ghci-flags) -no-ignore-dot-ghci $@

semantic-analysis/semantic-analysis.cabal

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ library
4040
import: common
4141
hs-source-dirs: src
4242
exposed-modules:
43-
Analysis.Analysis
43+
Analysis.Carrier.Env.Monovariant
44+
Analysis.Carrier.Env.Precise
45+
Analysis.Carrier.Heap.Monovariant
46+
Analysis.Carrier.Heap.Precise
4447
Analysis.Concrete
48+
Analysis.Effect.Domain
49+
Analysis.Effect.Env
50+
Analysis.Effect.Heap
4551
Analysis.File
4652
Analysis.FlowInsensitive
4753
Analysis.ImportGraph
48-
Analysis.ScopeGraph
54+
Analysis.Intro
55+
Analysis.Name
4956
Analysis.Typecheck
5057
Control.Carrier.Fail.WithLoc
5158
build-depends:
@@ -62,3 +69,4 @@ library
6269
, semantic-source ^>= 0
6370
, terminal-size ^>= 0.3
6471
, text ^>= 1.2.3.1
72+
, transformers ^>= 0.5

semantic-analysis/src/Analysis/Analysis.hs

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
2+
module Analysis.Carrier.Env.Monovariant
3+
( -- * Env carrier
4+
EnvC(..)
5+
-- * Env effect
6+
, module Analysis.Effect.Env
7+
) where
8+
9+
import Analysis.Effect.Env
10+
import Analysis.Name
11+
import Control.Algebra
12+
import qualified Control.Monad.Fail as Fail
13+
14+
newtype EnvC m a = EnvC { runEnv :: m a }
15+
deriving (Applicative, Functor, Monad, Fail.MonadFail)
16+
17+
instance Algebra sig m
18+
=> Algebra (Env Name :+: sig) (EnvC m) where
19+
alg (L (Alloc name k)) = k name
20+
alg (L (Bind _ _ m k)) = m >>= k
21+
alg (L (Lookup name k)) = k (Just name)
22+
alg (R other) = EnvC (alg (handleCoercible other))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
2+
module Analysis.Carrier.Env.Precise
3+
( -- * Env carrier
4+
EnvC(..)
5+
-- * Env effect
6+
, A.alloc
7+
, A.bind
8+
, A.lookupEnv
9+
, A.Env(..)
10+
) where
11+
12+
import qualified Analysis.Effect.Env as A
13+
import Analysis.Name
14+
import Control.Algebra
15+
import Control.Effect.Fresh
16+
import Control.Effect.Reader
17+
import qualified Control.Monad.Fail as Fail
18+
import qualified Data.Map as Map
19+
20+
type Precise = Int
21+
type Env = Map.Map Name Precise
22+
23+
newtype EnvC m a = EnvC { runEnv :: m a }
24+
deriving (Applicative, Functor, Monad, Fail.MonadFail)
25+
26+
instance ( Has Fresh sig m
27+
, Has (Reader Env) sig m
28+
)
29+
=> Algebra (A.Env Precise :+: sig) (EnvC m) where
30+
alg (L (A.Alloc _ k)) = fresh >>= k
31+
alg (L (A.Bind name addr m k)) = local (Map.insert name addr) m >>= k
32+
alg (L (A.Lookup name k)) = asks (Map.lookup name) >>= k
33+
alg (R other) = EnvC (alg (handleCoercible other))
Lines changed: 31 additions & 0 deletions

0 commit comments

Comments
 (0)