Skip to content

Commit

Permalink
Merge pull request #24 from ElaraLang/14-renamer-doesnt-seem-to-actua…
Browse files Browse the repository at this point in the history
…lly-take-into-account-whether-things-are-imported

Fix #14
  • Loading branch information
bristermitten committed Jun 1, 2024
2 parents f449390 + 8dca1bb commit 01aa7db
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 54 deletions.
3 changes: 1 addition & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ processModules graph (dumpShunted, dumpTyped) =
>=> traverseGraphRevTopologically inferModule
>=> dumpIf fst dumpTyped (view (_Unwrapped % unlocated % field' @"name" % to nameText)) ".typed.elr"
>=> traverseGraphRevTopologically (\(a, b) -> moduleToCore b a)
>=> pure
. mapGraph coreToCore
>=> (pure . mapGraph coreToCore)
$ graph
)
where
Expand Down
3 changes: 3 additions & 0 deletions elara.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ library
, safe-exceptions
, stringsearch
, terminal-size
, text-metrics
, utf8-string
mixins:
base hiding (Prelude)
Expand Down Expand Up @@ -231,6 +232,7 @@ executable elara
, safe-exceptions
, stringsearch
, terminal-size
, text-metrics
, utf8-string
mixins:
base hiding (Prelude)
Expand Down Expand Up @@ -312,6 +314,7 @@ test-suite elara-test
, safe-exceptions
, stringsearch
, terminal-size
, text-metrics
, utf8-string
mixins:
base hiding (Prelude)
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
- hashable
- process
- stringsearch
- text-metrics

ghc-options:
- -Wall
Expand Down
30 changes: 30 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# inspired by https://github.com/orhun/git-cliff/blob/main/release.sh

new_version=$(git cliff --bumped-version)
echo "New version: $new_version"

# update package.yaml version
sed -E -i '' "s/^version: \"[^\"]*\"$/version: \"${new_version#v}\"/" package.yaml
# and the cabal file
hpack


# Update changelog
git cliff --tag "${new_version}" > CHANGELOG.md
git add -A && git commit -m "chore(release): prepare for ${new_version}"
git show

# generate a changelog for the tag message
export GIT_CLIFF_TEMPLATE="\
{% for group, commits in commits | group_by(attribute=\"group\") %}
{{ group | upper_first }}\
{% for commit in commits %}
- {% if commit.breaking %}(breaking) {% endif %}{{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\
{% endfor %}
{% endfor %}"
changelog=$(git cliff --unreleased --strip all)

git tag -s -a "${new_version}" -m "Release ${new_version}" -m "${changelog}"
git tag -v "${new_version}"

echo "Release ready. Run 'git push --follow-tags' to push the changes and tags."
4 changes: 2 additions & 2 deletions source.elr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Prelude
import Option
import List
import Elara.Prim

let inc x = x + 1

let main =
print (Option.map inc (Some 5))
print (map incc (Some 5))
192 changes: 145 additions & 47 deletions src/Elara/Rename.hs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions stdlib/prelude.elr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Prelude
import Elara.Prim
import List

def (*>) : IO a -> IO b -> IO b
let (*>) a b = a >>= \x -> b
Expand Down
10 changes: 8 additions & 2 deletions test/Infer/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import Polysemy.Log
import Polysemy.Reader (runReader)
import Polysemy.State (State)
import Print (showPretty)
import Test.HUnit (assertFailure)

pattern Forall' :: UniqueTyVar -> Domain -> Type () -> Type ()
pattern Forall' name domain t = Forall () () name domain t
Expand All @@ -65,7 +64,14 @@ inferFully source = finalisePipeline . runInferPipeline . runShuntPipeline . run
tokens <- readTokensWith fp (toString source)
parsed <- parsePipeline exprParser fp (toString source, tokens)
desugared <- runDesugarPipeline $ runDesugar $ desugarExpr parsed
renamed <- runRenamePipeline (createGraph []) primitiveRenameState (runReader Nothing $ renameExpr desugared)
renamed <-
runRenamePipeline
(createGraph [])
primitiveRenameState
( runReader (Nothing @(Module 'Desugared)) $
runReader (Nothing @(Declaration 'Desugared)) $
renameExpr desugared
)
shunted <- runReader mempty $ shuntExpr renamed
inferExpression shunted Nothing >>= completeInference

Expand Down
3 changes: 2 additions & 1 deletion test/Shunt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Common (diagShouldSucceed)
import Elara.AST.Generic
import Elara.AST.Generic.Instances ()
import Elara.AST.Generic.Pattern (functionCall, int, var)
import Elara.AST.Module
import Elara.AST.Name (OpName (..), Qualified (..), VarName (OperatorVarName))
import Elara.AST.Region (generatedLocated)
import Elara.AST.Select (LocatedAST (..), UnlocatedAST (UnlocatedShunted))
Expand Down Expand Up @@ -33,7 +34,7 @@ loadExpr source = finalisePipeline . runShuntPipeline . runRenamePipeline (creat
parsed <- parsePipeline exprParser fp (toString source, tokens)
desugared <- runDesugarPipeline $ runDesugar $ desugarExpr parsed

renamed <- runReader Nothing $ renameExpr desugared
renamed <- runReader Nothing $ runReader (Nothing :: Maybe (Module 'Desugared)) $ renameExpr desugared
runReader fakeOperatorTable $ fixExpr renamed

mkFakeVar :: OpName -> VarRef VarName
Expand Down

0 comments on commit 01aa7db

Please sign in to comment.