Skip to content

Commit

Permalink
Split off unison-runtime package
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Aug 29, 2024
1 parent b6e12d0 commit 2fa330b
Show file tree
Hide file tree
Showing 46 changed files with 775 additions and 63 deletions.
5 changes: 5 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ cradle:

- path: "parser-typechecker/tests"
component: "unison-parser-typechecker:test:parser-typechecker-tests"
- path: "unison-runtime/src"
component: "unison-runtime:lib"

- path: "unison-runtime/tests"
component: "unison-runtime:test:runtime-tests"

- path: "unison-cli/src"
component: "unison-cli:lib"
Expand Down
5 changes: 0 additions & 5 deletions parser-typechecker/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ flags:
optimized:
manual: true
default: true
arraychecks:
manual: true
default: false

when:
- condition: flag(optimized)
ghc-options: -funbox-strict-fields -O2
- condition: flag(arraychecks)
cpp-options: -DARRAY_CHECK

dependencies:
- ListLike
Expand Down
9 changes: 0 additions & 9 deletions parser-typechecker/src/Unison/Codebase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ module Unison.Codebase
addDefsToCodebase,
componentReferencesForReference,
installUcmDependencies,
toCodeLookup,
typeLookupForDependencies,
unsafeGetComponentLength,
SqliteCodebase.Operations.emptyCausalHash,
Expand All @@ -132,7 +131,6 @@ import Unison.Builtin.Terms qualified as Builtin
import Unison.Codebase.Branch (Branch)
import Unison.Codebase.Branch qualified as Branch
import Unison.Codebase.BuiltinAnnotation (BuiltinAnnotation (builtinAnnotation))
import Unison.Codebase.CodeLookup qualified as CL
import Unison.Codebase.Path
import Unison.Codebase.Path qualified as Path
import Unison.Codebase.ProjectPath qualified as PP
Expand All @@ -153,7 +151,6 @@ import Unison.Project (ProjectAndBranch (ProjectAndBranch), ProjectBranchName, P
import Unison.Reference (Reference, TermReference, TermReferenceId, TypeReference)
import Unison.Reference qualified as Reference
import Unison.Referent qualified as Referent
import Unison.Runtime.IOSource qualified as IOSource
import Unison.Sqlite qualified as Sqlite
import Unison.Symbol (Symbol)
import Unison.Term (Term)
Expand Down Expand Up @@ -418,12 +415,6 @@ typeLookupForDependencies codebase s = do
<|> Map.lookup r (TL.effectDecls tl) $> ()
)

toCodeLookup :: (MonadIO m) => Codebase m Symbol Parser.Ann -> CL.CodeLookup Symbol m Parser.Ann
toCodeLookup c =
CL.CodeLookup (runTransaction c . getTerm c) (runTransaction c . getTypeDeclaration c)
<> Builtin.codeLookup
<> IOSource.codeLookupM

-- | Get the type of a term.
--
-- Note that it is possible to call 'putTerm', then 'getTypeOfTerm', and receive @Nothing@, per the semantics of
Expand Down
6 changes: 0 additions & 6 deletions parser-typechecker/tests/Suite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import System.IO
import System.IO.CodePage (withCP65001)
import Unison.Core.Test.Name qualified as Name
import Unison.Test.ABT qualified as ABT
import Unison.Test.ANF qualified as ANF
import Unison.Test.Codebase.Branch qualified as Branch
import Unison.Test.Codebase.Causal qualified as Causal
import Unison.Test.Codebase.Path qualified as Path
import Unison.Test.CodebaseInit qualified as CodebaseInit
import Unison.Test.DataDeclaration qualified as DataDeclaration
import Unison.Test.MCode qualified as MCode
import Unison.Test.Referent qualified as Referent
import Unison.Test.Syntax.FileParser qualified as FileParser
import Unison.Test.Syntax.TermParser qualified as TermParser
Expand All @@ -25,7 +23,6 @@ import Unison.Test.Type qualified as Type
import Unison.Test.Typechecker qualified as Typechecker
import Unison.Test.Typechecker.Context qualified as Context
import Unison.Test.Typechecker.TypeError qualified as TypeError
import Unison.Test.UnisonSources qualified as UnisonSources
import Unison.Test.Util.Relation qualified as Relation
import Unison.Test.Util.Text qualified as Text
import Unison.Test.Var qualified as Var
Expand All @@ -38,7 +35,6 @@ test =
Type.test,
TypeError.test,
TypePrinter.test,
UnisonSources.test,
FileParser.test,
DataDeclaration.test,
Text.test,
Expand All @@ -47,8 +43,6 @@ test =
Causal.test,
Referent.test,
ABT.test,
ANF.test,
MCode.test,
Var.test,
Typechecker.test,
Context.test,
Expand Down
34 changes: 0 additions & 34 deletions parser-typechecker/unison-parser-typechecker.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ source-repository head
type: git
location: https://github.com/unisonweb/unison

flag arraychecks
manual: True
default: False

flag optimized
manual: True
default: True
Expand Down Expand Up @@ -48,7 +44,6 @@ library
Unison.Codebase.CodeLookup.Util
Unison.Codebase.Editor.DisplayObject
Unison.Codebase.Editor.RemoteRepo
Unison.Codebase.Execute
Unison.Codebase.FileCodebase
Unison.Codebase.Init
Unison.Codebase.Init.CreateCodebaseError
Expand Down Expand Up @@ -133,27 +128,6 @@ library
Unison.PrettyPrintEnvDecl.Sqlite
Unison.PrintError
Unison.Result
Unison.Runtime.ANF
Unison.Runtime.ANF.Rehash
Unison.Runtime.ANF.Serialize
Unison.Runtime.Array
Unison.Runtime.Builtin
Unison.Runtime.Crypto.Rsa
Unison.Runtime.Debug
Unison.Runtime.Decompile
Unison.Runtime.Exception
Unison.Runtime.Foreign
Unison.Runtime.Foreign.Function
Unison.Runtime.Interface
Unison.Runtime.IOSource
Unison.Runtime.Machine
Unison.Runtime.MCode
Unison.Runtime.MCode.Serialize
Unison.Runtime.Pattern
Unison.Runtime.Serialize
Unison.Runtime.SparseVector
Unison.Runtime.Stack
Unison.Runtime.Vector
Unison.Share.Types
Unison.Syntax.DeclParser
Unison.Syntax.DeclPrinter
Expand Down Expand Up @@ -350,25 +324,20 @@ library
default-language: Haskell2010
if flag(optimized)
ghc-options: -funbox-strict-fields -O2
if flag(arraychecks)
cpp-options: -DARRAY_CHECK

test-suite parser-typechecker-tests
type: exitcode-stdio-1.0
main-is: Suite.hs
other-modules:
Unison.Core.Test.Name
Unison.Test.ABT
Unison.Test.ANF
Unison.Test.Codebase.Branch
Unison.Test.Codebase.Causal
Unison.Test.Codebase.Path
Unison.Test.CodebaseInit
Unison.Test.Common
Unison.Test.DataDeclaration
Unison.Test.MCode
Unison.Test.Referent
Unison.Test.Runtime.Crypto.Rsa
Unison.Test.Syntax.FileParser
Unison.Test.Syntax.TermParser
Unison.Test.Syntax.TypePrinter
Expand All @@ -378,7 +347,6 @@ test-suite parser-typechecker-tests
Unison.Test.Typechecker.Components
Unison.Test.Typechecker.Context
Unison.Test.Typechecker.TypeError
Unison.Test.UnisonSources
Unison.Test.Util.Pretty
Unison.Test.Util.Relation
Unison.Test.Util.Text
Expand Down Expand Up @@ -549,5 +517,3 @@ test-suite parser-typechecker-tests
default-language: Haskell2010
if flag(optimized)
ghc-options: -funbox-strict-fields -O2
if flag(arraychecks)
cpp-options: -DARRAY_CHECK
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ packages:
- unison-core
- unison-hashing-v2
- unison-merge
- unison-runtime
- unison-share-api
- unison-share-projects-api
- unison-syntax
Expand Down
1 change: 1 addition & 0 deletions unison-cli/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dependencies:
- unison-parser-typechecker
- unison-prelude
- unison-pretty-printer
- unison-runtime
- unison-share-api
- unison-share-projects-api
- unison-sqlite
Expand Down
3 changes: 2 additions & 1 deletion unison-cli/src/Unison/Codebase/Editor/HandleInput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import Unison.Codebase.Editor.RemoteRepo qualified as RemoteRepo
import Unison.Codebase.Editor.Slurp qualified as Slurp
import Unison.Codebase.Editor.SlurpResult qualified as SlurpResult
import Unison.Codebase.Editor.StructuredArgument qualified as SA
import Unison.Codebase.Execute qualified as Codebase
import Unison.Codebase.IntegrityCheck qualified as IntegrityCheck (integrityCheckFullCodebase)
import Unison.Codebase.Metadata qualified as Metadata
import Unison.Codebase.Path (Path, Path' (..))
Expand Down Expand Up @@ -1446,7 +1447,7 @@ doCompile native output main = do
| native = nativeRuntime
| otherwise = runtime
(ref, ppe) <- resolveMainRef main
let codeLookup = () <$ Codebase.toCodeLookup codebase
let codeLookup = () <$ Codebase.codebaseToCodeLookup codebase
outf
| native = output
| otherwise = output <> ".uc"
Expand Down
3 changes: 2 additions & 1 deletion unison-cli/src/Unison/Codebase/Editor/HandleInput/Load.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Unison.Codebase qualified as Codebase
import Unison.Codebase.Editor.HandleInput.RuntimeUtils qualified as RuntimeUtils
import Unison.Codebase.Editor.Output qualified as Output
import Unison.Codebase.Editor.Slurp qualified as Slurp
import Unison.Codebase.Execute qualified as Codebase
import Unison.Codebase.Runtime qualified as Runtime
import Unison.FileParsers qualified as FileParsers
import Unison.Names (Names)
Expand Down Expand Up @@ -192,7 +193,7 @@ evalUnisonFile mode ppe unisonFile args = do

Cli.with_ (withArgs args) do
(nts, errs, map) <-
Cli.ioE (Runtime.evaluateWatches (Codebase.toCodeLookup codebase) ppe watchCache theRuntime unisonFile) \err -> do
Cli.ioE (Runtime.evaluateWatches (Codebase.codebaseToCodeLookup codebase) ppe watchCache theRuntime unisonFile) \err -> do
Cli.returnEarly (Output.EvaluationFailure err)
when (not $ null errs) (RuntimeUtils.displayDecompileErrors errs)
for_ (Map.elems map) \(_loc, kind, hash, _src, value, isHit) -> do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Unison.Cli.Monad (Cli)
import Unison.Cli.Monad qualified as Cli
import Unison.Codebase qualified as Codebase
import Unison.Codebase.Editor.Output
import Unison.Codebase.Execute qualified as Codebase
import Unison.Codebase.Runtime qualified as Runtime
import Unison.Hashing.V2.Convert qualified as Hashing
import Unison.Parser.Ann (Ann (..))
Expand Down Expand Up @@ -55,7 +56,7 @@ evalUnisonTermE sandbox ppe useCache tm = do
pure (Term.amap (\(_ :: Ann) -> ()) <$> maybeTerm)

let cache = if useCache then watchCache else Runtime.noCache
r <- liftIO (Runtime.evaluateTerm' (Codebase.toCodeLookup codebase) cache ppe theRuntime tm)
r <- liftIO (Runtime.evaluateTerm' (Codebase.codebaseToCodeLookup codebase) cache ppe theRuntime tm)
when useCache do
case r of
Right (errs, tmr)
Expand Down
3 changes: 3 additions & 0 deletions unison-cli/unison-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ library
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
, unison-runtime
, unison-share-api
, unison-share-projects-api
, unison-sqlite
Expand Down Expand Up @@ -415,6 +416,7 @@ executable transcripts
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
, unison-runtime
, unison-share-api
, unison-share-projects-api
, unison-sqlite
Expand Down Expand Up @@ -563,6 +565,7 @@ test-suite cli-tests
, unison-parser-typechecker
, unison-prelude
, unison-pretty-printer
, unison-runtime
, unison-share-api
, unison-share-projects-api
, unison-sqlite
Expand Down
19 changes: 19 additions & 0 deletions unison-runtime/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2013-2021, Unison Computing, public benefit corp and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit 2fa330b

Please sign in to comment.