Stabel

Check-in [3d59be640a]
Login
Overview
Comment:Rename every reference from Play to Stabel.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3d59be640a52d3e885ddb313ef303c180a4bde71de53e565bff0413ec67a5037
User & Date: robin.hansen on 2021-06-03 09:33:46
Other Links: manifest | tags
Context
2021-06-03
09:44
Remove elm/html as dependency. Update elm-community/list-extra. check-in: 328065d9cb user: robin.hansen tags: trunk
09:33
Rename every reference from Play to Stabel. check-in: 3d59be640a user: robin.hansen tags: trunk
09:33
Change string literals that contains 'play' to reference 'stabel' instead. Closed-Leaf check-in: 4fffdf1ce2 user: robin.hansen tags: rebranding
08:46
Update dependencies check-in: 001e644fe1 user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified bin/cli.js from [30c9406240] to [15abce7081].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    if (subCmdFlags.length !== 1) {
        console.error("'init' requires exactly one argument: the package name.");
        return;
    }

    fs.mkdirSync(path.join(cwd, "src"));

    const playJson = {
        name: subCmdFlags[0],
        version: "0.1.0",
        "language-version": "0.2.0",
        "exposed-modules": [
            "main"
        ],
        dependencies: {
            "play/standard_library": "0.2.0"
        },
        "package-paths": []
    };

    fs.writeFileSync(path.join(cwd, "play.json"), JSON.stringify(playJson, null, 4));

    fs.writeFileSync(path.join(cwd, "src", "main.play"), `
def: execute
: 0
`.trim());
}

function runProject() {
    if (subCmdFlags.length !== 1) {
................................................................................
        return;
    }

    compileProject(subCmdFlags[0]);
}

function compileProject(entryPoint) {
    const rootJsonMetaPath = path.join(cwd, "play.json");
    if (!fs.existsSync(rootJsonMetaPath)) {
        console.error("No 'play.json' file found in this directory.");
        return;
    }

    const compiler = require(__dirname + "/compiler").Elm.CLI.init({
        flags: {
            projectDir: cwd,
            entryPoint: typeof entryPoint === "undefined" ? null : entryPoint,
................................................................................
                    fileName: msg.fileName,
                    content: fileContent
                });
                break;
            case "resolvePackageModules":
                const srcPath = path.join(msg.path, "src");
                const childrenFiles = expandDir(msg.path)("src")
                    .filter(name => name.endsWith(".play"))
                    .map(name => name.replace(srcPath + "/", ""));

                compiler.ports.incomingPort.send({
                    type: "resolvedPackageModules",
                    package: msg.package,
                    modules: childrenFiles
                });
................................................................................
    };
}

function packageDirs(parentDir) {
    return fs.readdirSync(parentDir)
        .map(dir => path.join(parentDir, dir))
        .filter(dir => fs.statSync(dir).isDirectory())
        .filter(dir => fs.readdirSync(dir).indexOf('play.json') >= 0);
}

function printHelp() {
    console.log(`
Play compiler. Alpha-2.

Possible options are:
* init <package_name>: initialize a new project in the current directory.
* compile: compile the project.
* run <function_name>: compile the project and execute the given function.
* help: print this help message.
    `);







|







|




|

|







 







|

|







 







|







 







|




|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    if (subCmdFlags.length !== 1) {
        console.error("'init' requires exactly one argument: the package name.");
        return;
    }

    fs.mkdirSync(path.join(cwd, "src"));

    const stabelJson = {
        name: subCmdFlags[0],
        version: "0.1.0",
        "language-version": "0.2.0",
        "exposed-modules": [
            "main"
        ],
        dependencies: {
            "stabel/standard_library": "0.2.0"
        },
        "package-paths": []
    };

    fs.writeFileSync(path.join(cwd, "stabel.json"), JSON.stringify(stabelJson, null, 4));

    fs.writeFileSync(path.join(cwd, "src", "main.stbl"), `
def: execute
: 0
`.trim());
}

function runProject() {
    if (subCmdFlags.length !== 1) {
................................................................................
        return;
    }

    compileProject(subCmdFlags[0]);
}

function compileProject(entryPoint) {
    const rootJsonMetaPath = path.join(cwd, "stabel.json");
    if (!fs.existsSync(rootJsonMetaPath)) {
        console.error("No 'stabel.json' file found in this directory.");
        return;
    }

    const compiler = require(__dirname + "/compiler").Elm.CLI.init({
        flags: {
            projectDir: cwd,
            entryPoint: typeof entryPoint === "undefined" ? null : entryPoint,
................................................................................
                    fileName: msg.fileName,
                    content: fileContent
                });
                break;
            case "resolvePackageModules":
                const srcPath = path.join(msg.path, "src");
                const childrenFiles = expandDir(msg.path)("src")
                    .filter(name => name.endsWith(".stbl"))
                    .map(name => name.replace(srcPath + "/", ""));

                compiler.ports.incomingPort.send({
                    type: "resolvedPackageModules",
                    package: msg.package,
                    modules: childrenFiles
                });
................................................................................
    };
}

function packageDirs(parentDir) {
    return fs.readdirSync(parentDir)
        .map(dir => path.join(parentDir, dir))
        .filter(dir => fs.statSync(dir).isDirectory())
        .filter(dir => fs.readdirSync(dir).indexOf('stabel.json') >= 0);
}

function printHelp() {
    console.log(`
Stabel v0.2.0-alpha

Possible options are:
* init <package_name>: initialize a new project in the current directory.
* compile: compile the project.
* run <function_name>: compile the project and execute the given function.
* help: print this help message.
    `);

Modified package-lock.json from [473bdddb66] to [313b7a3fa5].

1
2
3
4
5
6
7
8
9
10
{
  "name": "play",
  "version": "0.0.1",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "@babel/code-frame": {
      "version": "7.12.13",
      "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
      "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==",

|
|







1
2
3
4
5
6
7
8
9
10
{
  "name": "stabel",
  "version": "0.2.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "@babel/code-frame": {
      "version": "7.12.13",
      "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
      "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==",

Modified package.json from [88a397ca10] to [efe2408db9].

1
2
3
4
5
6
7
8
9
10
11
..
17
18
19
20
21
22
23
24
25
26
{
  "name": "play",
  "version": "0.0.1",
  "description": "",
  "author": "Robin Heggelund Hansen",
  "license": "MIT",
  "dependencies": {},
  "devDependencies": {
    "elm": "^0.19.1-5",
    "elm-format": "^0.8.5",
    "elm-test": "^0.19.1-revision7",
................................................................................
    "test": "npm run test:elm && npm run test:wasm",
    "test:elm": "elm-test",
    "test:elm:watch": "elm-test --watch",
    "test:wasm": "elm make src/TestCompiler.elm --output wasm_tests/compiler.js && sed -i '' \"s/console.warn\\(.*\\);/\\/*&*\\//g\" wasm_tests/compiler.js && jest",
    "build": "elm make src/CLI.elm --output bin/compiler.js && sed -i '' \"s/console.warn\\(.*\\);/\\/*&*\\//g\" bin/compiler.js"
  },
  "bin": {
    "play": "bin/cli.js"
  }
}

|
|
|







 







|


1
2
3
4
5
6
7
8
9
10
11
..
17
18
19
20
21
22
23
24
25
26
{
  "name": "stabel",
  "version": "0.2.0",
  "description": "A pure concatinative programming language, that targets web assembly",
  "author": "Robin Heggelund Hansen",
  "license": "MIT",
  "dependencies": {},
  "devDependencies": {
    "elm": "^0.19.1-5",
    "elm-format": "^0.8.5",
    "elm-test": "^0.19.1-revision7",
................................................................................
    "test": "npm run test:elm && npm run test:wasm",
    "test:elm": "elm-test",
    "test:elm:watch": "elm-test --watch",
    "test:wasm": "elm make src/TestCompiler.elm --output wasm_tests/compiler.js && sed -i '' \"s/console.warn\\(.*\\);/\\/*&*\\//g\" wasm_tests/compiler.js && jest",
    "build": "elm make src/CLI.elm --output bin/compiler.js && sed -i '' \"s/console.warn\\(.*\\);/\\/*&*\\//g\" bin/compiler.js"
  },
  "bin": {
    "stabel": "bin/cli.js"
  }
}

Modified src/CLI.elm from [c955eddac9] to [c0ba24cd83].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
port module CLI exposing (main)

import Json.Decode as Json
import Json.Encode as Encode
import Platform exposing (Program)
import Play.Codegen as Codegen
import Play.Data.PackagePath as PackagePath
import Play.PackageLoader as PackageLoader
import Play.TypeChecker as TypeChecker
import Play.TypeChecker.Problem as TypeCheckerProblem
import Wasm


type alias Flags =
    { projectDir : String
    , entryPoint : Maybe String
    , stdLibPath : String





|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
port module CLI exposing (main)

import Json.Decode as Json
import Json.Encode as Encode
import Platform exposing (Program)
import Stabel.Codegen as Codegen
import Stabel.Data.PackagePath as PackagePath
import Stabel.PackageLoader as PackageLoader
import Stabel.TypeChecker as TypeChecker
import Stabel.TypeChecker.Problem as TypeCheckerProblem
import Wasm


type alias Flags =
    { projectDir : String
    , entryPoint : Maybe String
    , stdLibPath : String

Modified src/Stabel/Codegen.elm from [785ddad7e6] to [f0e0af3247].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Play.Codegen exposing (..)

import Dict exposing (Dict)
import List.Extra as List
import Play.Codegen.BaseModule as BaseModule
import Play.Data.Builtin as Builtin exposing (Builtin)
import Play.Data.Type as Type exposing (Type, WordType)
import Play.TypeChecker as AST exposing (AST)
import Wasm


type alias TypeInformation =
    { id : Int
    , members : List ( String, Type )
    }
|



|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Stabel.Codegen exposing (..)

import Dict exposing (Dict)
import List.Extra as List
import Stabel.Codegen.BaseModule as BaseModule
import Stabel.Data.Builtin as Builtin exposing (Builtin)
import Stabel.Data.Type as Type exposing (Type, WordType)
import Stabel.TypeChecker as AST exposing (AST)
import Wasm


type alias TypeInformation =
    { id : Int
    , members : List ( String, Type )
    }

Modified src/Stabel/Codegen/BaseModule.elm from [20f472e2d6] to [00776dc6c5].

1
2
3
4
5
6
7
8
module Play.Codegen.BaseModule exposing (..)

import Wasm



-- Constants

|







1
2
3
4
5
6
7
8
module Stabel.Codegen.BaseModule exposing (..)

import Wasm



-- Constants

Modified src/Stabel/Data/Builtin.elm from [0bf08e2fda] to [f4b853399b].

1
2
3
4
5
6
7
8
9
10
module Play.Data.Builtin exposing (..)

import Play.Data.Type as Type exposing (WordType)


type Builtin
    = Plus
    | Minus
    | Multiply
    | Divide
|

|







1
2
3
4
5
6
7
8
9
10
module Stabel.Data.Builtin exposing (..)

import Stabel.Data.Type as Type exposing (WordType)


type Builtin
    = Plus
    | Minus
    | Multiply
    | Divide

Modified src/Stabel/Data/Metadata.elm from [4a5e9363a6] to [510597f370].

1
2
3
4
5
6
7
8
9
10
11
12
13
module Play.Data.Metadata exposing (..)

import Dict exposing (Dict)
import Play.Data.SourceLocation exposing (SourceLocationRange)
import Play.Data.Type exposing (Type)
import Play.Data.TypeSignature exposing (TypeSignature(..))


type alias Metadata =
    { isEntryPoint : Bool
    , type_ : TypeSignature
    , isQuoted : Bool
    , sourceLocationRange : Maybe SourceLocationRange
|


|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
module Stabel.Data.Metadata exposing (..)

import Dict exposing (Dict)
import Stabel.Data.SourceLocation exposing (SourceLocationRange)
import Stabel.Data.Type exposing (Type)
import Stabel.Data.TypeSignature exposing (TypeSignature(..))


type alias Metadata =
    { isEntryPoint : Bool
    , type_ : TypeSignature
    , isQuoted : Bool
    , sourceLocationRange : Maybe SourceLocationRange

Modified src/Stabel/Data/ModuleName.elm from [1e115d5ae1] to [7acfd2f72d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Play.Data.ModuleName exposing
    ( ModuleName
    , fromString
    , toPartStrings
    , toString
    )

import Play.Data.PackageName as PackageName


type ModuleName
    = ModuleName String


fromString : String -> Result () ModuleName
|






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Stabel.Data.ModuleName exposing
    ( ModuleName
    , fromString
    , toPartStrings
    , toString
    )

import Stabel.Data.PackageName as PackageName


type ModuleName
    = ModuleName String


fromString : String -> Result () ModuleName

Modified src/Stabel/Data/PackageMetadata.elm from [cab47e39e5] to [f79d36c524].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Play.Data.PackageMetadata exposing
    ( PackageMetadata
    , decoder
    )

import Dict exposing (Dict)
import Json.Decode as Json
import Play.Data.ModuleName as ModuleName exposing (ModuleName)
import Play.Data.PackageName as PackageName exposing (PackageName)
import Play.Data.PackagePath as PackagePath exposing (PackagePath)
import Play.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)


type alias PackageMetadata =
    { name : PackageName
    , version : SemanticVersion
    , compatibleLanguageVersion : SemanticVersion
    , exposedModules : List ModuleName
|






|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Stabel.Data.PackageMetadata exposing
    ( PackageMetadata
    , decoder
    )

import Dict exposing (Dict)
import Json.Decode as Json
import Stabel.Data.ModuleName as ModuleName exposing (ModuleName)
import Stabel.Data.PackageName as PackageName exposing (PackageName)
import Stabel.Data.PackagePath as PackagePath exposing (PackagePath)
import Stabel.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)


type alias PackageMetadata =
    { name : PackageName
    , version : SemanticVersion
    , compatibleLanguageVersion : SemanticVersion
    , exposedModules : List ModuleName

Modified src/Stabel/Data/PackageName.elm from [83dc1a13a9] to [4c8f109469].

1
2
3
4
5
6
7
8
module Play.Data.PackageName exposing
    ( PackageName
    , fromString
    , invalidPart
    , toString
    )


|







1
2
3
4
5
6
7
8
module Stabel.Data.PackageName exposing
    ( PackageName
    , fromString
    , invalidPart
    , toString
    )


Modified src/Stabel/Data/PackagePath.elm from [1e9585ddbd] to [a00d165d99].

1
2
3
4
5
6
7
8
module Play.Data.PackagePath exposing
    ( PackagePath(..)
    , fromString
    , prefix
    )


type PackagePath
|







1
2
3
4
5
6
7
8
module Stabel.Data.PackagePath exposing
    ( PackagePath(..)
    , fromString
    , prefix
    )


type PackagePath

Modified src/Stabel/Data/SemanticVersion.elm from [b8b4cd3223] to [83ff2799b0].

1
2
3
4
5
6
7
8
module Play.Data.SemanticVersion exposing
    ( Compatibility(..)
    , ParseError(..)
    , SemanticVersion
    , compatible
    , fromString
    )

|







1
2
3
4
5
6
7
8
module Stabel.Data.SemanticVersion exposing
    ( Compatibility(..)
    , ParseError(..)
    , SemanticVersion
    , compatible
    , fromString
    )

Modified src/Stabel/Data/SourceLocation.elm from [40ebfca2d9] to [6c04d804ba].

1
2
3
4
5
6
7
8
module Play.Data.SourceLocation exposing (..)


type alias SourceLocationRange =
    { start : SourceLocation
    , end : SourceLocation
    }

|







1
2
3
4
5
6
7
8
module Stabel.Data.SourceLocation exposing (..)


type alias SourceLocationRange =
    { start : SourceLocation
    , end : SourceLocation
    }

Modified src/Stabel/Data/Type.elm from [7660e71094] to [54096b4f0c].

1
2
3
4
5
6
7
8
module Play.Data.Type exposing
    ( Type(..)
    , WordType
    , compatibleWords
    , emptyWordType
    , genericName
    , genericlyCompatible
    , isGeneric
|







1
2
3
4
5
6
7
8
module Stabel.Data.Type exposing
    ( Type(..)
    , WordType
    , compatibleWords
    , emptyWordType
    , genericName
    , genericlyCompatible
    , isGeneric

Modified src/Stabel/Data/TypeSignature.elm from [7ee4340b00] to [87ce6f3109].

1
2
3
4
5
6
7
8
9
10
module Play.Data.TypeSignature exposing (..)

import Play.Data.Type exposing (WordType)


type TypeSignature
    = NotProvided
    | UserProvided WordType
    | CompilerProvided WordType

|

|







1
2
3
4
5
6
7
8
9
10
module Stabel.Data.TypeSignature exposing (..)

import Stabel.Data.Type exposing (WordType)


type TypeSignature
    = NotProvided
    | UserProvided WordType
    | CompilerProvided WordType

Modified src/Stabel/PackageLoader.elm from [2e56b7cc2e] to [5e78c07643].

1
2
3
4
5
6
7
8
9
10
11
12
13
14


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
...
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
module Play.PackageLoader exposing
    ( Model(..)
    , Msg(..)
    , Problem(..)
    , SideEffect(..)
    , getSideEffect
    , init
    , problemToString
    , update
    )

import Dict exposing (Dict)
import Json.Decode as Json
import List.Extra as List


import Play.Data.Metadata as Metadata
import Play.Data.ModuleName as ModuleName exposing (ModuleName)
import Play.Data.PackageMetadata as PackageMetadata exposing (PackageMetadata)
import Play.Data.PackageName as PackageName exposing (PackageName)
import Play.Data.PackagePath as PackagePath exposing (PackagePath)
import Play.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)
import Play.Parser as Parser
import Play.Parser.Problem as ParserProblem
import Play.Qualifier as Qualifier
import Play.Qualifier.Problem as QualifierProblem
import Result.Extra as Result
import Set exposing (Set)


type Problem
    = InvalidPackageMetadata String String
    | UnknownMessageForState String
    | NoExposedModulesInRootProject
    | ModuleNotFound String
................................................................................
        Parsing _ _ sf ->
            Just sf


init : InitOptions -> Model
init initOptions =
    Initializing initOptions <|
        ReadFile initOptions.projectDirPath "play.json"


update : Msg -> Model -> Model
update msg model =
    case model of
        Initializing initOpts _ ->
            case msg of
................................................................................
                            case pathsToLoad of
                                [] ->
                                    ResolvingModulePaths state [] <|
                                        ResolvePackageModules (PackageName.toString metadata.name) path

                                (PackagePath.Directory nextPathDir) :: _ ->
                                    LoadingMetadata state pathsToLoad <|
                                        ReadFile nextPathDir "play.json"

                                (PackagePath.AllDirectoriesInDirectory nextPathDir) :: _ ->
                                    LoadingMetadata state pathsToLoad <|
                                        ResolveDirectories nextPathDir

                        Err err ->
                            Failed <| InvalidPackageMetadata path <| Json.errorToString err
................................................................................
                        (ResolvePackageModules
                            (PackageName.toString nextState.rootPackage.metadata.name)
                            nextState.rootPackage.path
                        )

                (PackagePath.Directory nextPathDir) :: _ ->
                    LoadingMetadata nextState pathsToLoad <|
                        ReadFile nextPathDir "play.json"

                (PackagePath.AllDirectoriesInDirectory nextPathDir) :: _ ->
                    LoadingMetadata nextState pathsToLoad <|
                        ResolveDirectories (pathPrefix ++ nextPathDir)
    in
    case msg of
        FileContents path _ content ->
................................................................................
    case msg of
        ResolvedPackageModules packageName modules ->
            let
                rootPackage =
                    state.rootPackage

                moduleNameResults =
                    List.map (String.replace ".play" "") modules
                        |> List.map ModuleName.fromString
                        |> Result.combine

                updatedRemainingPackages =
                    List.filter (\p -> PackageName.toString p.metadata.name /= packageName) remainingPackages

                nextStep newState =
................................................................................
    let
        ( path, fileName ) =
            case List.reverse (ModuleName.toPartStrings moduleName) of
                name :: reversePath ->
                    ( reversePath
                        |> List.reverse
                        |> String.join "/"
                    , name ++ ".play"
                    )

                _ ->
                    ( "", "" )
    in
    ( [ packagePath, "src", path ]
        |> List.filter (not << String.isEmpty)
|













>
>
|
|
|
|
|
|
|
|
|
|
<
<







 







|







 







|







 







|







 







|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


27
28
29
30
31
32
33
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
...
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
module Stabel.PackageLoader exposing
    ( Model(..)
    , Msg(..)
    , Problem(..)
    , SideEffect(..)
    , getSideEffect
    , init
    , problemToString
    , update
    )

import Dict exposing (Dict)
import Json.Decode as Json
import List.Extra as List
import Result.Extra as Result
import Set exposing (Set)
import Stabel.Data.Metadata as Metadata
import Stabel.Data.ModuleName as ModuleName exposing (ModuleName)
import Stabel.Data.PackageMetadata as PackageMetadata exposing (PackageMetadata)
import Stabel.Data.PackageName as PackageName exposing (PackageName)
import Stabel.Data.PackagePath as PackagePath exposing (PackagePath)
import Stabel.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)
import Stabel.Parser as Parser
import Stabel.Parser.Problem as ParserProblem
import Stabel.Qualifier as Qualifier
import Stabel.Qualifier.Problem as QualifierProblem




type Problem
    = InvalidPackageMetadata String String
    | UnknownMessageForState String
    | NoExposedModulesInRootProject
    | ModuleNotFound String
................................................................................
        Parsing _ _ sf ->
            Just sf


init : InitOptions -> Model
init initOptions =
    Initializing initOptions <|
        ReadFile initOptions.projectDirPath "stabel.json"


update : Msg -> Model -> Model
update msg model =
    case model of
        Initializing initOpts _ ->
            case msg of
................................................................................
                            case pathsToLoad of
                                [] ->
                                    ResolvingModulePaths state [] <|
                                        ResolvePackageModules (PackageName.toString metadata.name) path

                                (PackagePath.Directory nextPathDir) :: _ ->
                                    LoadingMetadata state pathsToLoad <|
                                        ReadFile nextPathDir "stabel.json"

                                (PackagePath.AllDirectoriesInDirectory nextPathDir) :: _ ->
                                    LoadingMetadata state pathsToLoad <|
                                        ResolveDirectories nextPathDir

                        Err err ->
                            Failed <| InvalidPackageMetadata path <| Json.errorToString err
................................................................................
                        (ResolvePackageModules
                            (PackageName.toString nextState.rootPackage.metadata.name)
                            nextState.rootPackage.path
                        )

                (PackagePath.Directory nextPathDir) :: _ ->
                    LoadingMetadata nextState pathsToLoad <|
                        ReadFile nextPathDir "stabel.json"

                (PackagePath.AllDirectoriesInDirectory nextPathDir) :: _ ->
                    LoadingMetadata nextState pathsToLoad <|
                        ResolveDirectories (pathPrefix ++ nextPathDir)
    in
    case msg of
        FileContents path _ content ->
................................................................................
    case msg of
        ResolvedPackageModules packageName modules ->
            let
                rootPackage =
                    state.rootPackage

                moduleNameResults =
                    List.map (String.replace ".stbl" "") modules
                        |> List.map ModuleName.fromString
                        |> Result.combine

                updatedRemainingPackages =
                    List.filter (\p -> PackageName.toString p.metadata.name /= packageName) remainingPackages

                nextStep newState =
................................................................................
    let
        ( path, fileName ) =
            case List.reverse (ModuleName.toPartStrings moduleName) of
                name :: reversePath ->
                    ( reversePath
                        |> List.reverse
                        |> String.join "/"
                    , name ++ ".stbl"
                    )

                _ ->
                    ( "", "" )
    in
    ( [ packagePath, "src", path ]
        |> List.filter (not << String.isEmpty)

Modified src/Stabel/Parser.elm from [fcb864ece6] to [86504ca9cd].

1
2
3
4
5
6
7
8
..
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Play.Parser exposing
    ( AST
    , AstNode(..)
    , ModuleDefinition(..)
    , ModuleDefinitionRec
    , PossiblyQualifiedType(..)
    , TypeDefinition(..)
    , TypeMatch(..)
................................................................................
    , typeDefinitionName
    , typeSignatureToMaybe
    )

import Dict exposing (Dict)
import Dict.Extra as Dict
import Parser.Advanced as Parser exposing ((|.), (|=), Token(..))
import Play.Data.SourceLocation exposing (SourceLocation, SourceLocationRange)
import Play.Parser.Problem exposing (..)
import Set exposing (Set)


type alias Parser a =
    Parser.Parser () Problem a


type alias AST =
|







 







|
|
|







1
2
3
4
5
6
7
8
..
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Stabel.Parser exposing
    ( AST
    , AstNode(..)
    , ModuleDefinition(..)
    , ModuleDefinitionRec
    , PossiblyQualifiedType(..)
    , TypeDefinition(..)
    , TypeMatch(..)
................................................................................
    , typeDefinitionName
    , typeSignatureToMaybe
    )

import Dict exposing (Dict)
import Dict.Extra as Dict
import Parser.Advanced as Parser exposing ((|.), (|=), Token(..))
import Set exposing (Set)
import Stabel.Data.SourceLocation exposing (SourceLocation, SourceLocationRange)
import Stabel.Parser.Problem exposing (..)


type alias Parser a =
    Parser.Parser () Problem a


type alias AST =

Modified src/Stabel/Parser/Problem.elm from [7563961c4b] to [082d961418].

1
2
3
4
5
6
7
8
9
10
11
12
13
module Play.Parser.Problem exposing
    ( Problem(..)
    , toString
    )

import Play.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)


type Problem
    = NotInt
    | NotSymbol
    | NotMetadata
    | NotGeneric
|




|







1
2
3
4
5
6
7
8
9
10
11
12
13
module Stabel.Parser.Problem exposing
    ( Problem(..)
    , toString
    )

import Stabel.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)


type Problem
    = NotInt
    | NotSymbol
    | NotMetadata
    | NotGeneric

Modified src/Stabel/Qualifier.elm from [0a582ab702] to [73e4b7b24b].

1
2
3
4


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
module Play.Qualifier exposing (..)

import Dict exposing (Dict)
import List.Extra as List


import Play.Data.Builtin as Builtin exposing (Builtin)
import Play.Data.Metadata as Metadata exposing (Metadata)
import Play.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)
import Play.Data.Type as Type exposing (Type, WordType)
import Play.Data.TypeSignature as TypeSignature
import Play.Parser as Parser
import Play.Qualifier.Problem exposing (Problem(..))
import Result.Extra as Result
import Set exposing (Set)


type alias AST =
    { types : Dict String TypeDefinition
    , words : Dict String WordDefinition
    }

................................................................................
    }


moduleDefinition : ModuleDefinitionConfig a -> Parser.ModuleDefinitionRec
moduleDefinition config =
    let
        defaultImports =
            if Dict.get "/core" config.externalModules == Just "play/standard_library" then
                Dict.fromList [ ( "/core", [] ) ]

            else
                Dict.empty
    in
    case config.ast.moduleDefinition of
        Parser.Undefined ->
|



>
>
|
|
|
|
|
|
|
<
<







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
module Stabel.Qualifier exposing (..)

import Dict exposing (Dict)
import List.Extra as List
import Result.Extra as Result
import Set exposing (Set)
import Stabel.Data.Builtin as Builtin exposing (Builtin)
import Stabel.Data.Metadata as Metadata exposing (Metadata)
import Stabel.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)
import Stabel.Data.Type as Type exposing (Type, WordType)
import Stabel.Data.TypeSignature as TypeSignature
import Stabel.Parser as Parser
import Stabel.Qualifier.Problem exposing (Problem(..))




type alias AST =
    { types : Dict String TypeDefinition
    , words : Dict String WordDefinition
    }

................................................................................
    }


moduleDefinition : ModuleDefinitionConfig a -> Parser.ModuleDefinitionRec
moduleDefinition config =
    let
        defaultImports =
            if Dict.get "/core" config.externalModules == Just "stabel/standard_library" then
                Dict.fromList [ ( "/core", [] ) ]

            else
                Dict.empty
    in
    case config.ast.moduleDefinition of
        Parser.Undefined ->

Modified src/Stabel/Qualifier/Problem.elm from [cf36a1d3b1] to [76de36ead2].

1
2
3
4
5
6
7
8
9
10
11
12
13
module Play.Qualifier.Problem exposing
    ( Problem(..)
    , toString
    )

import Play.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)


type Problem
    = UnknownWordRef SourceLocationRange String
    | UnknownTypeRef SourceLocationRange String
    | UnionTypeMatchWithPatterns SourceLocationRange
    | InvalidTypeMatch SourceLocationRange
|




|







1
2
3
4
5
6
7
8
9
10
11
12
13
module Stabel.Qualifier.Problem exposing
    ( Problem(..)
    , toString
    )

import Stabel.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)


type Problem
    = UnknownWordRef SourceLocationRange String
    | UnknownTypeRef SourceLocationRange String
    | UnionTypeMatchWithPatterns SourceLocationRange
    | InvalidTypeMatch SourceLocationRange

Modified src/Stabel/TypeChecker.elm from [267b56b8c9] to [0164e41594].

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Play.TypeChecker exposing (..)

import Dict exposing (Dict)
import Dict.Extra as Dict
import List.Extra as List

import Play.Data.Builtin as Builtin exposing (Builtin)
import Play.Data.Metadata exposing (Metadata)
import Play.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)
import Play.Data.Type as Type exposing (Type, WordType)
import Play.Data.TypeSignature as TypeSignature exposing (TypeSignature)
import Play.Qualifier as Qualifier
import Play.TypeChecker.Problem exposing (Problem(..))
import Set exposing (Set)


type alias AST =
    { types : Dict String TypeDefinition
    , words : Dict String WordDefinition
    }

|




>
|
|
|
|
|
|
|
<







1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
module Stabel.TypeChecker exposing (..)

import Dict exposing (Dict)
import Dict.Extra as Dict
import List.Extra as List
import Set exposing (Set)
import Stabel.Data.Builtin as Builtin exposing (Builtin)
import Stabel.Data.Metadata exposing (Metadata)
import Stabel.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)
import Stabel.Data.Type as Type exposing (Type, WordType)
import Stabel.Data.TypeSignature as TypeSignature exposing (TypeSignature)
import Stabel.Qualifier as Qualifier
import Stabel.TypeChecker.Problem exposing (Problem(..))



type alias AST =
    { types : Dict String TypeDefinition
    , words : Dict String WordDefinition
    }

Modified src/Stabel/TypeChecker/Problem.elm from [63d1018a02] to [fdbd9948ec].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Play.TypeChecker.Problem exposing
    ( Problem(..)
    , toString
    )

import Play.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)
import Play.Data.Type as Type exposing (Type, WordType)
import Set exposing (Set)


type Problem
    = UndeclaredGeneric SourceLocationRange String (Set String)
    | TypeError SourceLocationRange String WordType WordType
    | UnexpectedType SourceLocationRange String Type Type
    | InconsistentWhens SourceLocationRange String
|




|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Stabel.TypeChecker.Problem exposing
    ( Problem(..)
    , toString
    )

import Set exposing (Set)
import Stabel.Data.SourceLocation as SourceLocation exposing (SourceLocationRange)
import Stabel.Data.Type as Type exposing (Type, WordType)


type Problem
    = UndeclaredGeneric SourceLocationRange String (Set String)
    | TypeError SourceLocationRange String WordType WordType
    | UnexpectedType SourceLocationRange String Type Type
    | InconsistentWhens SourceLocationRange String

Modified src/TestCompiler.elm from [3223a451b4] to [85fae358af].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
port module TestCompiler exposing (main)

import Dict
import Platform exposing (Program)
import Play.Codegen as Codegen
import Play.Data.Metadata as Metadata
import Play.Parser as Parser
import Play.Parser.Problem as ParserProblem
import Play.Qualifier as Qualifier
import Play.Qualifier.Problem as QualifierProblem
import Play.TypeChecker as TypeChecker
import Play.TypeChecker.Problem as TypeCheckerProblem
import Wasm


type alias Model =
    ()






|
|
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
port module TestCompiler exposing (main)

import Dict
import Platform exposing (Program)
import Stabel.Codegen as Codegen
import Stabel.Data.Metadata as Metadata
import Stabel.Parser as Parser
import Stabel.Parser.Problem as ParserProblem
import Stabel.Qualifier as Qualifier
import Stabel.Qualifier.Problem as QualifierProblem
import Stabel.TypeChecker as TypeChecker
import Stabel.TypeChecker.Problem as TypeCheckerProblem
import Wasm


type alias Model =
    ()


Name change from stdlib/src/core.play to stdlib/src/core.stbl.

Name change from stdlib/src/list.play to stdlib/src/list.stbl.

Name change from stdlib/src/maybe.play to stdlib/src/maybe.stbl.

Name change from stdlib/src/pair.play to stdlib/src/pair.stbl.

Modified stdlib/stabel.json from [f2261f0ba9] to [89a8117702].

1
2
3
4
5
6
7
8
9
10
11
12
13
{
    "name": "play/standard_library",
    "version": "0.2.0",
    "language-version": "0.2.0",
    "exposed-modules": [
        "core",
        "maybe",
        "pair",
        "list"
    ],
    "dependencies": {},
    "package-paths": []
}

|











1
2
3
4
5
6
7
8
9
10
11
12
13
{
    "name": "stabel/standard_library",
    "version": "0.2.0",
    "language-version": "0.2.0",
    "exposed-modules": [
        "core",
        "maybe",
        "pair",
        "list"
    ],
    "dependencies": {},
    "package-paths": []
}

Modified tests/Test/Data/ModuleName.elm from [96d969b684] to [c91b0806b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
module Test.Data.ModuleName exposing (suite)

import Expect
import Fuzz
import Play.Data.ModuleName as ModuleName
import Play.Data.PackageName as PackageName
import Test exposing (Test, describe, fuzz, test)


suite : Test
suite =
    describe "ModuleName"
        [ fuzz Fuzz.string "Valid 2-part module names are also valid package names" <|




|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
module Test.Data.ModuleName exposing (suite)

import Expect
import Fuzz
import Stabel.Data.ModuleName as ModuleName
import Stabel.Data.PackageName as PackageName
import Test exposing (Test, describe, fuzz, test)


suite : Test
suite =
    describe "ModuleName"
        [ fuzz Fuzz.string "Valid 2-part module names are also valid package names" <|

Modified tests/Test/Data/PackageName.elm from [bcb092c8ca] to [f605b6f096].

1
2
3
4
5
6

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Test.Data.PackageName exposing (suite)

import Expect
import Play.Data.PackageName as PackageName
import Test exposing (Test, describe, test)
import Test.PlayExpect as PlayExpect



suite : Test
suite =
    describe "PackageName"
        [ test "valid package names" <|
            \_ ->
                PlayExpect.allOk PackageName.fromString
                    [ "some/package"
                    , "play/std_lib"
                    , "number1/package123"
                    , "play_std/lib"
                    ]
        , test "Must contain exactly two parts, seperated by a single slash" <|
            \_ ->
                PlayExpect.allErr PackageName.fromString
                    [ "/"
                    , "one/"
                    , "/one"
                    , "one"
                    , "one/two/three"
                    ]
        , test "Both parts of a name must start with lower cased ascii character" <|
            \_ ->
                PlayExpect.allErr PackageName.fromString
                    [ "1pack/name"
                    , "_priv/pack"
                    , "#whaaat/events"
                    , "Some/package"
                    , "pack/1name"
                    , "priv/_pack"
                    , "whaaat/#events"
                    , "some/Package"
                    ]
        , test "Both parts of a name cannot contain upper case letters" <|
            \_ ->
                PlayExpect.allErr PackageName.fromString
                    [ "myPack/name"
                    , "mypackage/someName"
                    , "mypackage/some_Name"
                    ]
        , test "Both parts of a name cannot contain non ascii or digit letters" <|
            \_ ->
                PlayExpect.allErr PackageName.fromString
                    [ "my#pack/name"
                    , "mypackage/bills$"
                    ]
        ]


<
|

<
>







|

|

|



|








|











|






|




1
2

3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module Test.Data.PackageName exposing (suite)


import Stabel.Data.PackageName as PackageName
import Test exposing (Test, describe, test)

import Test.StabelExpect as StabelExpect


suite : Test
suite =
    describe "PackageName"
        [ test "valid package names" <|
            \_ ->
                StabelExpect.allOk PackageName.fromString
                    [ "some/package"
                    , "stabel/std_lib"
                    , "number1/package123"
                    , "stabel_std/lib"
                    ]
        , test "Must contain exactly two parts, seperated by a single slash" <|
            \_ ->
                StabelExpect.allErr PackageName.fromString
                    [ "/"
                    , "one/"
                    , "/one"
                    , "one"
                    , "one/two/three"
                    ]
        , test "Both parts of a name must start with lower cased ascii character" <|
            \_ ->
                StabelExpect.allErr PackageName.fromString
                    [ "1pack/name"
                    , "_priv/pack"
                    , "#whaaat/events"
                    , "Some/package"
                    , "pack/1name"
                    , "priv/_pack"
                    , "whaaat/#events"
                    , "some/Package"
                    ]
        , test "Both parts of a name cannot contain upper case letters" <|
            \_ ->
                StabelExpect.allErr PackageName.fromString
                    [ "myPack/name"
                    , "mypackage/someName"
                    , "mypackage/some_Name"
                    ]
        , test "Both parts of a name cannot contain non ascii or digit letters" <|
            \_ ->
                StabelExpect.allErr PackageName.fromString
                    [ "my#pack/name"
                    , "mypackage/bills$"
                    ]
        ]

Modified tests/Test/Data/PackagePath.elm from [156de36d36] to [4f8b1dae93].

1
2
3
4
5
6
7
8
9
10
11
module Test.Data.PackagePath exposing (suite)

import Expect
import Play.Data.PackagePath as PackagePath
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "PackagePath"
        [ test "Any path not ending in * is a directory" <|



|







1
2
3
4
5
6
7
8
9
10
11
module Test.Data.PackagePath exposing (suite)

import Expect
import Stabel.Data.PackagePath as PackagePath
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "PackagePath"
        [ test "Any path not ending in * is a directory" <|

Modified tests/Test/Data/SemanticVersion.elm from [831feac96b] to [8a6bda5641].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module Test.Data.SemanticVersion exposing (suite)

import Expect
import Play.Data.SemanticVersion as SemanticVersion
import Test exposing (Test, describe, test)
import Test.PlayExpect as PlayExpect


suite : Test
suite =
    describe "SemanticVersion"
        [ test "Valid versions" <|
            \_ ->
                PlayExpect.allOk SemanticVersion.fromString
                    [ "1.2.3"
                    , "10.100.1000"
                    , "0.0.1"
                    , "0.1.0"
                    ]
        , test "Cannot contain more than three parts" <|
            \_ ->
                SemanticVersion.fromString "1.2.3.4"
                    |> Expect.equal (Err <| SemanticVersion.InvalidFormat "1.2.3.4")
        , test "Cannot contain less than three parts" <|
            \_ ->
                PlayExpect.allEqual SemanticVersion.fromString
                    [ ( "1", Err <| SemanticVersion.InvalidFormat "1" )
                    , ( "1.2", Err <| SemanticVersion.InvalidFormat "1.2" )
                    ]
        , test "Cannot be empty string" <|
            \_ ->
                SemanticVersion.fromString ""
                    |> Expect.equal (Err <| SemanticVersion.InvalidFormat "")
        , test "Must be numbers" <|
            \_ ->
                PlayExpect.allEqual SemanticVersion.fromString
                    [ ( "A", Err <| SemanticVersion.InvalidFormat "A" )
                    , ( "*", Err <| SemanticVersion.InvalidFormat "*" )
                    , ( "~", Err <| SemanticVersion.InvalidFormat "~" )
                    , ( "1.0.x", Err <| SemanticVersion.ExpectedInteger "1.0.x" )
                    , ( "1.0.~", Err <| SemanticVersion.ExpectedInteger "1.0.~" )
                    , ( "~1.0.0", Err <| SemanticVersion.ExpectedInteger "~1.0.0" )
                    , ( "1.0.0-alpha1", Err <| SemanticVersion.ExpectedInteger "1.0.0-alpha1" )
................................................................................
                    ]
        , test "Minimum version is 0.0.1" <|
            \_ ->
                SemanticVersion.fromString "0.0.0"
                    |> Expect.equal (Err <| SemanticVersion.LessThanMinimumVersion "0.0.0")
        , test "Cannot contain negative versions" <|
            \_ ->
                PlayExpect.allEqual SemanticVersion.fromString
                    [ ( "-1.0.0", Err <| SemanticVersion.NegativeVersions "-1.0.0" )
                    , ( "1.-2.0", Err <| SemanticVersion.NegativeVersions "1.-2.0" )
                    , ( "1.2.-3", Err <| SemanticVersion.NegativeVersions "1.2.-3" )
                    ]
        , describe "Compatibility" <|
            let
                helper ( lhs, rhs ) =
                    Result.map2 SemanticVersion.compatible (SemanticVersion.fromString lhs) (SemanticVersion.fromString rhs)
            in
            [ test "Same version, or greater version, returns GreaterThanOrEqual" <|
                \_ ->
                    PlayExpect.allEqual helper
                        [ ( ( "1.0.0", "1.0.0" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "0.2.1", "0.2.1" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "2.0.8", "2.0.8" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "1.0.0", "1.2.0" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "2.1.0", "2.1.1" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "1.2.3", "1.3.0" ), Ok SemanticVersion.GreaterThanOrEqual )
                        ]
            , test "Lesser version returns LessThan" <|
                \_ ->
                    PlayExpect.allEqual helper
                        [ ( ( "0.2.1", "0.2.0" ), Ok SemanticVersion.LessThan )
                        , ( ( "1.1.0", "1.0.5" ), Ok SemanticVersion.LessThan )
                        , ( ( "2.1.3", "2.1.1" ), Ok SemanticVersion.LessThan )
                        , ( ( "1.2.3", "1.2.2" ), Ok SemanticVersion.LessThan )
                        ]
            , test "Incompatible versions" <|
                \_ ->
                    PlayExpect.allEqual helper
                        [ ( ( "0.2.1", "0.3.0" ), Ok SemanticVersion.Incompatible )
                        , ( ( "1.0.0", "2.0.0" ), Ok SemanticVersion.Incompatible )
                        , ( ( "1.2.0", "2.2.0" ), Ok SemanticVersion.Incompatible )
                        , ( ( "0.0.1", "1.0.1" ), Ok SemanticVersion.Incompatible )
                        ]
            ]
        ]



|

|







|











|









|







 







|











|









|







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module Test.Data.SemanticVersion exposing (suite)

import Expect
import Stabel.Data.SemanticVersion as SemanticVersion
import Test exposing (Test, describe, test)
import Test.StabelExpect as StabelExpect


suite : Test
suite =
    describe "SemanticVersion"
        [ test "Valid versions" <|
            \_ ->
                StabelExpect.allOk SemanticVersion.fromString
                    [ "1.2.3"
                    , "10.100.1000"
                    , "0.0.1"
                    , "0.1.0"
                    ]
        , test "Cannot contain more than three parts" <|
            \_ ->
                SemanticVersion.fromString "1.2.3.4"
                    |> Expect.equal (Err <| SemanticVersion.InvalidFormat "1.2.3.4")
        , test "Cannot contain less than three parts" <|
            \_ ->
                StabelExpect.allEqual SemanticVersion.fromString
                    [ ( "1", Err <| SemanticVersion.InvalidFormat "1" )
                    , ( "1.2", Err <| SemanticVersion.InvalidFormat "1.2" )
                    ]
        , test "Cannot be empty string" <|
            \_ ->
                SemanticVersion.fromString ""
                    |> Expect.equal (Err <| SemanticVersion.InvalidFormat "")
        , test "Must be numbers" <|
            \_ ->
                StabelExpect.allEqual SemanticVersion.fromString
                    [ ( "A", Err <| SemanticVersion.InvalidFormat "A" )
                    , ( "*", Err <| SemanticVersion.InvalidFormat "*" )
                    , ( "~", Err <| SemanticVersion.InvalidFormat "~" )
                    , ( "1.0.x", Err <| SemanticVersion.ExpectedInteger "1.0.x" )
                    , ( "1.0.~", Err <| SemanticVersion.ExpectedInteger "1.0.~" )
                    , ( "~1.0.0", Err <| SemanticVersion.ExpectedInteger "~1.0.0" )
                    , ( "1.0.0-alpha1", Err <| SemanticVersion.ExpectedInteger "1.0.0-alpha1" )
................................................................................
                    ]
        , test "Minimum version is 0.0.1" <|
            \_ ->
                SemanticVersion.fromString "0.0.0"
                    |> Expect.equal (Err <| SemanticVersion.LessThanMinimumVersion "0.0.0")
        , test "Cannot contain negative versions" <|
            \_ ->
                StabelExpect.allEqual SemanticVersion.fromString
                    [ ( "-1.0.0", Err <| SemanticVersion.NegativeVersions "-1.0.0" )
                    , ( "1.-2.0", Err <| SemanticVersion.NegativeVersions "1.-2.0" )
                    , ( "1.2.-3", Err <| SemanticVersion.NegativeVersions "1.2.-3" )
                    ]
        , describe "Compatibility" <|
            let
                helper ( lhs, rhs ) =
                    Result.map2 SemanticVersion.compatible (SemanticVersion.fromString lhs) (SemanticVersion.fromString rhs)
            in
            [ test "Same version, or greater version, returns GreaterThanOrEqual" <|
                \_ ->
                    StabelExpect.allEqual helper
                        [ ( ( "1.0.0", "1.0.0" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "0.2.1", "0.2.1" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "2.0.8", "2.0.8" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "1.0.0", "1.2.0" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "2.1.0", "2.1.1" ), Ok SemanticVersion.GreaterThanOrEqual )
                        , ( ( "1.2.3", "1.3.0" ), Ok SemanticVersion.GreaterThanOrEqual )
                        ]
            , test "Lesser version returns LessThan" <|
                \_ ->
                    StabelExpect.allEqual helper
                        [ ( ( "0.2.1", "0.2.0" ), Ok SemanticVersion.LessThan )
                        , ( ( "1.1.0", "1.0.5" ), Ok SemanticVersion.LessThan )
                        , ( ( "2.1.3", "2.1.1" ), Ok SemanticVersion.LessThan )
                        , ( ( "1.2.3", "1.2.2" ), Ok SemanticVersion.LessThan )
                        ]
            , test "Incompatible versions" <|
                \_ ->
                    StabelExpect.allEqual helper
                        [ ( ( "0.2.1", "0.3.0" ), Ok SemanticVersion.Incompatible )
                        , ( ( "1.0.0", "2.0.0" ), Ok SemanticVersion.Incompatible )
                        , ( ( "1.2.0", "2.2.0" ), Ok SemanticVersion.Incompatible )
                        , ( ( "0.0.1", "1.0.1" ), Ok SemanticVersion.Incompatible )
                        ]
            ]
        ]

Modified tests/Test/PackageLoader.elm from [670203e2f4] to [08472bdfab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
...
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
module Test.PackageLoader exposing (suite)

import Dict exposing (Dict)
import Dict.Extra as Dict
import Expect exposing (Expectation)
import List.Extra as List
import Play.Data.Builtin as Builtin
import Play.Data.Metadata as Metadata
import Play.Data.PackagePath as PackagePath
import Play.Data.SourceLocation exposing (emptyRange)
import Play.PackageLoader as PackageLoader
import Play.Qualifier as Qualifier
import Test exposing (Test, describe, test)
import Test.Qualifier.Util as Util


suite : Test
suite =
    let
................................................................................
            , stdLibPath = "/project/lib/unused"
            }
    in
    describe "PackageLoader"
        [ test "Passes the load package metadata step" <|
            \_ ->
                PackageLoader.init initOpts
                    |> Expect.equal (PackageLoader.Initializing initOpts <| PackageLoader.ReadFile "/project" "play.json")
        , test "Retrieves necessary files" <|
            \_ ->
                PackageLoader.init initOpts
                    |> expectSideEffects testFiles
                        [ PackageLoader.ReadFile "/project" "play.json"
                        , PackageLoader.ReadFile "/project/lib/template_strings" "play.json"
                        , PackageLoader.ResolveDirectories "/project/lib/template_strings/lib"
                        , PackageLoader.ReadFile "/project/lib/template_strings/lib/version" "play.json"
                        , PackageLoader.ReadFile "/project/lib/unused" "play.json"
                        , PackageLoader.ReadFile "/project/lib/version" "play.json"
                        , PackageLoader.ResolvePackageModules "robheghan/fnv" "/project"
                        , PackageLoader.ResolvePackageModules "jarvis/template_strings" "/project/lib/template_strings"
                        , PackageLoader.ResolvePackageModules "play/version" "/project/lib/template_strings/lib/version"
                        , PackageLoader.ReadFile "/project/src" "mod1.play"
                        , PackageLoader.ReadFile "/project/lib/template_strings/lib/version/src/version" "data.play"
                        ]
        , test "Compiles project with external dependencies to qualified AST" <|
            \_ ->
                let
                    loaderResult =
                        PackageLoader.init initOpts
                            |> resolveSideEffects testFiles []
................................................................................
                                Dict.fromListBy Qualifier.typeDefinitionName []
                            , words =
                                Dict.fromListBy .name
                                    [ { name = "/robheghan/fnv/mod1/next-version"
                                      , metadata = Metadata.default
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Word emptyRange "/play/version/version/data/number"
                                                , Qualifier.Integer emptyRange 1
                                                , Qualifier.Builtin emptyRange Builtin.Plus
                                                ]
                                      }
                                    , { name = "/play/version/version/data/number"
                                      , metadata = Metadata.default
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Integer emptyRange 2
                                                ]
                                      }
                                    ]
................................................................................
                            (Util.stripLocations ast)
        , test "Specified entry point is marked as such" <|
            \_ ->
                let
                    loaderResult =
                        PackageLoader.init
                            { projectDirPath = "/project"
                            , possibleEntryPoint = Just "/play/version/version/data/number"
                            , stdLibPath = initOpts.stdLibPath
                            }
                            |> resolveSideEffects testFiles []
                            |> Result.map Tuple.second
                in
                case loaderResult of
                    Err msg ->
................................................................................
                                Dict.fromListBy Qualifier.typeDefinitionName []
                            , words =
                                Dict.fromListBy .name
                                    [ { name = "/robheghan/fnv/mod1/next-version"
                                      , metadata = Metadata.default
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Word emptyRange "/play/version/version/data/number"
                                                , Qualifier.Integer emptyRange 1
                                                , Qualifier.Builtin emptyRange Builtin.Plus
                                                ]
                                      }
                                    , { name = "/play/version/version/data/number"
                                      , metadata =
                                            Metadata.default
                                                |> Metadata.asEntryPoint
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Integer emptyRange 2
                                                ]
................................................................................
                            Err <| "No such file: " ++ path

                PackageLoader.ResolveDirectories dir ->
                    let
                        childPaths =
                            Dict.keys fileSystem
                                |> List.filter (childPackage dir)
                                |> List.map (String.replace "/play.json" "")
                                |> List.map PackagePath.Directory
                    in
                    resolveSideEffects
                        fileSystem
                        (sideEffect :: seenSfs)
                        (PackageLoader.update
                            (PackageLoader.ResolvedDirectories dir childPaths)
................................................................................
        let
            pathParts =
                path
                    |> String.replace (targetDir ++ "/") ""
                    |> String.split "/"
        in
        case pathParts of
            [ _, "play.json" ] ->
                True

            _ ->
                False


stdLibFiles : Dict String String
stdLibFiles =
    Dict.fromList
        [ ( "/project/lib/unused/play.json"
          , """
            {
                "name": "some/useless",
                "version": "1.7.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "useless/mod"
................................................................................
                "dependencies": {
                },
                "package-paths": [
                ]
            }
          """
          )
        , ( "/project/lib/unused/src/useless/mod.play"
          , """
            def: square
            : dup *
            """
          )
        ]


testFiles : Dict String String
testFiles =
    Dict.fromList
        [ ( "/project/play.json"
          , """
            {
                "name": "robheghan/fnv",
                "version": "1.0.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "mod1"
                ],
                "dependencies": {
                    "jarvis/template_strings": "1.2.0",
                    "play/version": "1.0.0"
                },
                "package-paths": [
                    "lib/template_strings",
                    "lib/version"
                ]
            }
            """
          )
        , ( "/project/src/mod1.play"
          , """
            def: next-version
            : /version/data/number 1 +
            """
          )
        , ( "/project/lib/template_strings/play.json"
          , """
            {
                "name": "jarvis/template_strings",
                "version": "1.2.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "template_strings/mod"
                ],
                "dependencies": {
                    "play/version": "1.1.0"
                },
                "package-paths": [
                    "lib/*"
                ]
            }
          """
          )
        , ( "/project/lib/template_strings/src/template_strings/mod.play"
          , """
            def: dec
            : 1 =
            """
          )
        , ( "/project/lib/version/play.json"
          , """
            {
                "name": "play/version",
                "version": "1.0.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "version/data"
                ],
                "dependencies": {
                },
                "package-paths": [
                ]
            }
          """
          )
        , ( "/project/lib/version/src/version/data.play"
          , """
            def: number
            : 1
            """
          )
        , ( "/project/lib/template_strings/lib/version/play.json"
          , """
            {
                "name": "play/version",
                "version": "1.2.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "version/data"
                ],
                "dependencies": {
                },
                "package-paths": [
                ]
            }
          """
          )
        , ( "/project/lib/template_strings/lib/version/src/version/data.play"
          , """
            def: number
            : 2
            """
          )
        ]
        |> Dict.union stdLibFiles


testFilesInternalConsistency : Dict String String
testFilesInternalConsistency =
    Dict.fromList
        [ ( "/project/play.json"
          , """
            {
                "name": "robheghan/dummy",
                "version": "1.0.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "mod1",
................................................................................
                    "mod3"
                ],
                "dependencies": {},
                "package-paths": []
            }
            """
          )
        , ( "/project/src/mod1.play"
          , """
            def: bump-version
            : 1 +
            """
          )
        , ( "/project/src/mod2.play"
          , """
            def: version
            : 5
            """
          )
        , ( "/project/src/mod3.play"
          , """
            def: next-version
            : mod2/version mod1/bump-version
            """
          )
        ]
        |> Dict.union stdLibFiles






|
|
|
|
|
|







 







|




|
|

|
|
|


|
|
|







 







|




|







 







|







 







|




|







 







|







 







|









|







 







|











|










|








|





|









|







|





|


|












|





|


|












|












|







 







|





|





|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
...
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
module Test.PackageLoader exposing (suite)

import Dict exposing (Dict)
import Dict.Extra as Dict
import Expect exposing (Expectation)
import List.Extra as List
import Stabel.Data.Builtin as Builtin
import Stabel.Data.Metadata as Metadata
import Stabel.Data.PackagePath as PackagePath
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.PackageLoader as PackageLoader
import Stabel.Qualifier as Qualifier
import Test exposing (Test, describe, test)
import Test.Qualifier.Util as Util


suite : Test
suite =
    let
................................................................................
            , stdLibPath = "/project/lib/unused"
            }
    in
    describe "PackageLoader"
        [ test "Passes the load package metadata step" <|
            \_ ->
                PackageLoader.init initOpts
                    |> Expect.equal (PackageLoader.Initializing initOpts <| PackageLoader.ReadFile "/project" "stabel.json")
        , test "Retrieves necessary files" <|
            \_ ->
                PackageLoader.init initOpts
                    |> expectSideEffects testFiles
                        [ PackageLoader.ReadFile "/project" "stabel.json"
                        , PackageLoader.ReadFile "/project/lib/template_strings" "stabel.json"
                        , PackageLoader.ResolveDirectories "/project/lib/template_strings/lib"
                        , PackageLoader.ReadFile "/project/lib/template_strings/lib/version" "stabel.json"
                        , PackageLoader.ReadFile "/project/lib/unused" "stabel.json"
                        , PackageLoader.ReadFile "/project/lib/version" "stabel.json"
                        , PackageLoader.ResolvePackageModules "robheghan/fnv" "/project"
                        , PackageLoader.ResolvePackageModules "jarvis/template_strings" "/project/lib/template_strings"
                        , PackageLoader.ResolvePackageModules "stabel/version" "/project/lib/template_strings/lib/version"
                        , PackageLoader.ReadFile "/project/src" "mod1.stbl"
                        , PackageLoader.ReadFile "/project/lib/template_strings/lib/version/src/version" "data.stbl"
                        ]
        , test "Compiles project with external dependencies to qualified AST" <|
            \_ ->
                let
                    loaderResult =
                        PackageLoader.init initOpts
                            |> resolveSideEffects testFiles []
................................................................................
                                Dict.fromListBy Qualifier.typeDefinitionName []
                            , words =
                                Dict.fromListBy .name
                                    [ { name = "/robheghan/fnv/mod1/next-version"
                                      , metadata = Metadata.default
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Word emptyRange "/stabel/version/version/data/number"
                                                , Qualifier.Integer emptyRange 1
                                                , Qualifier.Builtin emptyRange Builtin.Plus
                                                ]
                                      }
                                    , { name = "/stabel/version/version/data/number"
                                      , metadata = Metadata.default
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Integer emptyRange 2
                                                ]
                                      }
                                    ]
................................................................................
                            (Util.stripLocations ast)
        , test "Specified entry point is marked as such" <|
            \_ ->
                let
                    loaderResult =
                        PackageLoader.init
                            { projectDirPath = "/project"
                            , possibleEntryPoint = Just "/stabel/version/version/data/number"
                            , stdLibPath = initOpts.stdLibPath
                            }
                            |> resolveSideEffects testFiles []
                            |> Result.map Tuple.second
                in
                case loaderResult of
                    Err msg ->
................................................................................
                                Dict.fromListBy Qualifier.typeDefinitionName []
                            , words =
                                Dict.fromListBy .name
                                    [ { name = "/robheghan/fnv/mod1/next-version"
                                      , metadata = Metadata.default
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Word emptyRange "/stabel/version/version/data/number"
                                                , Qualifier.Integer emptyRange 1
                                                , Qualifier.Builtin emptyRange Builtin.Plus
                                                ]
                                      }
                                    , { name = "/stabel/version/version/data/number"
                                      , metadata =
                                            Metadata.default
                                                |> Metadata.asEntryPoint
                                      , implementation =
                                            Qualifier.SoloImpl
                                                [ Qualifier.Integer emptyRange 2
                                                ]
................................................................................
                            Err <| "No such file: " ++ path

                PackageLoader.ResolveDirectories dir ->
                    let
                        childPaths =
                            Dict.keys fileSystem
                                |> List.filter (childPackage dir)
                                |> List.map (String.replace "/stabel.json" "")
                                |> List.map PackagePath.Directory
                    in
                    resolveSideEffects
                        fileSystem
                        (sideEffect :: seenSfs)
                        (PackageLoader.update
                            (PackageLoader.ResolvedDirectories dir childPaths)
................................................................................
        let
            pathParts =
                path
                    |> String.replace (targetDir ++ "/") ""
                    |> String.split "/"
        in
        case pathParts of
            [ _, "stabel.json" ] ->
                True

            _ ->
                False


stdLibFiles : Dict String String
stdLibFiles =
    Dict.fromList
        [ ( "/project/lib/unused/stabel.json"
          , """
            {
                "name": "some/useless",
                "version": "1.7.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "useless/mod"
................................................................................
                "dependencies": {
                },
                "package-paths": [
                ]
            }
          """
          )
        , ( "/project/lib/unused/src/useless/mod.stbl"
          , """
            def: square
            : dup *
            """
          )
        ]


testFiles : Dict String String
testFiles =
    Dict.fromList
        [ ( "/project/stabel.json"
          , """
            {
                "name": "robheghan/fnv",
                "version": "1.0.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "mod1"
                ],
                "dependencies": {
                    "jarvis/template_strings": "1.2.0",
                    "stabel/version": "1.0.0"
                },
                "package-paths": [
                    "lib/template_strings",
                    "lib/version"
                ]
            }
            """
          )
        , ( "/project/src/mod1.stbl"
          , """
            def: next-version
            : /version/data/number 1 +
            """
          )
        , ( "/project/lib/template_strings/stabel.json"
          , """
            {
                "name": "jarvis/template_strings",
                "version": "1.2.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "template_strings/mod"
                ],
                "dependencies": {
                    "stabel/version": "1.1.0"
                },
                "package-paths": [
                    "lib/*"
                ]
            }
          """
          )
        , ( "/project/lib/template_strings/src/template_strings/mod.stbl"
          , """
            def: dec
            : 1 =
            """
          )
        , ( "/project/lib/version/stabel.json"
          , """
            {
                "name": "stabel/version",
                "version": "1.0.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "version/data"
                ],
                "dependencies": {
                },
                "package-paths": [
                ]
            }
          """
          )
        , ( "/project/lib/version/src/version/data.stbl"
          , """
            def: number
            : 1
            """
          )
        , ( "/project/lib/template_strings/lib/version/stabel.json"
          , """
            {
                "name": "stabel/version",
                "version": "1.2.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "version/data"
                ],
                "dependencies": {
                },
                "package-paths": [
                ]
            }
          """
          )
        , ( "/project/lib/template_strings/lib/version/src/version/data.stbl"
          , """
            def: number
            : 2
            """
          )
        ]
        |> Dict.union stdLibFiles


testFilesInternalConsistency : Dict String String
testFilesInternalConsistency =
    Dict.fromList
        [ ( "/project/stabel.json"
          , """
            {
                "name": "robheghan/dummy",
                "version": "1.0.0",
                "language-version": "0.2.0",
                "exposed-modules": [
                    "mod1",
................................................................................
                    "mod3"
                ],
                "dependencies": {},
                "package-paths": []
            }
            """
          )
        , ( "/project/src/mod1.stbl"
          , """
            def: bump-version
            : 1 +
            """
          )
        , ( "/project/src/mod2.stbl"
          , """
            def: version
            : 5
            """
          )
        , ( "/project/src/mod3.stbl"
          , """
            def: next-version
            : mod2/version mod1/bump-version
            """
          )
        ]
        |> Dict.union stdLibFiles

Modified tests/Test/Parser.elm from [e119fc8848] to [6e738c2708].

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Test.Parser exposing (..)

import Dict
import Dict.Extra as Dict
import Expect

import Play.Data.SourceLocation
    exposing
        ( SourceLocation
        , SourceLocationRange
        , emptyRange
        )
import Play.Parser as AST exposing (..)
import Set
import Test exposing (Test, describe, test)
import Test.Parser.Util
    exposing
        ( addFunctionsForStructs
        , compile
        , compileRetainLocations
        , expectCompiles





>
|





|
<







1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
module Test.Parser exposing (..)

import Dict
import Dict.Extra as Dict
import Expect
import Set
import Stabel.Data.SourceLocation
    exposing
        ( SourceLocation
        , SourceLocationRange
        , emptyRange
        )
import Stabel.Parser as AST exposing (..)

import Test exposing (Test, describe, test)
import Test.Parser.Util
    exposing
        ( addFunctionsForStructs
        , compile
        , compileRetainLocations
        , expectCompiles

Modified tests/Test/Parser/Error.elm from [297a7bb4eb] to [aa4f3e7ab5].

1
2
3
4
5
6
7
8
9
10
11
12
module Test.Parser.Error exposing (..)

import Expect exposing (Expectation)
import Play.Parser exposing (..)
import Play.Parser.Problem exposing (Problem(..))
import Test exposing (Test, describe, test)
import Test.Parser.Util exposing (compile)


suite : Test
suite =
    describe "Parser errors"



|
|







1
2
3
4
5
6
7
8
9
10
11
12
module Test.Parser.Error exposing (..)

import Expect exposing (Expectation)
import Stabel.Parser exposing (..)
import Stabel.Parser.Problem exposing (Problem(..))
import Test exposing (Test, describe, test)
import Test.Parser.Util exposing (compile)


suite : Test
suite =
    describe "Parser errors"

Modified tests/Test/Parser/Util.elm from [c6efc18281] to [69907d4d01].

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    , compileRetainLocations
    , expectCompiles
    )

import Dict
import Dict.Extra as Dict
import Expect
import Play.Data.Metadata as Metadata
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type exposing (Type)
import Play.Parser as AST exposing (..)
import Play.Parser.Problem exposing (Problem)
import String.Extra as String


compile : String -> Result (List Problem) AST
compile str =
    compileRetainLocations str
        |> Result.map stripLocations







|
|
|
|
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    , compileRetainLocations
    , expectCompiles
    )

import Dict
import Dict.Extra as Dict
import Expect
import Stabel.Data.Metadata as Metadata
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.Data.Type as Type exposing (Type)
import Stabel.Parser as AST exposing (..)
import Stabel.Parser.Problem exposing (Problem)
import String.Extra as String


compile : String -> Result (List Problem) AST
compile str =
    compileRetainLocations str
        |> Result.map stripLocations

Modified tests/Test/Qualifier.elm from [a69b471d1a] to [b5a4899f2d].

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
...
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
...
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
....
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
....
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
....
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
....
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
module Test.Qualifier exposing (..)

import Dict
import Dict.Extra as Dict
import Expect

import Play.Data.Builtin as Builtin
import Play.Data.Metadata as Metadata
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type
import Play.Parser as AST
import Play.Qualifier exposing (..)
import Play.Qualifier.Problem as Problem
import Set
import Test exposing (Test, describe, test)
import Test.Parser.Util as ParserUtil
import Test.Qualifier.Util as QualifierUtil


suite : Test
suite =
................................................................................
                            |> QualifierUtil.addFunctionsForStructs
                in
                QualifierUtil.expectOutput unqualifiedAst expectedAst
        , test "Name mangling" <|
            \_ ->
                let
                    qualifiedUsMoneyUnion =
                        [ Type.Custom "/play/test/some/module/Dollar"
                        , Type.Custom "/play/test/some/module/Cent"
                        ]

                    unqualifiedAst =
                        { moduleDefinition = AST.emptyModuleDefinition
                        , types =
                            Dict.fromListBy AST.typeDefinitionName
                                [ AST.UnionTypeDef emptyRange
................................................................................
                        }
                            |> ParserUtil.addFunctionsForStructs

                    expectedAst =
                        { types =
                            Dict.fromListBy typeDefinitionName
                                [ UnionTypeDef
                                    "/play/test/some/module/USMoney"
                                    True
                                    emptyRange
                                    []
                                    qualifiedUsMoneyUnion
                                , CustomTypeDef "/play/test/some/module/Dollar"
                                    True
                                    emptyRange
                                    []
                                    [ ( "dollar-value", Type.Int ) ]
                                , CustomTypeDef "/play/test/some/module/Cent"
                                    True
                                    emptyRange
                                    []
                                    [ ( "cent-value", Type.Int ) ]
                                ]
                        , words =
                            Dict.fromListBy .name
                                [ { name = "/play/test/some/module/into-cents"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatch emptyRange (Type.Custom "/play/test/some/module/Dollar") []
                                              , [ Word emptyRange "/play/test/some/module/dollar-value>"
                                                , Integer emptyRange 100
                                                , Builtin emptyRange Builtin.Multiply
                                                ]
                                              )
                                            , ( TypeMatch emptyRange (Type.Custom "/play/test/some/module/Cent") []
                                              , [ Word emptyRange "/play/test/some/module/cent-value>"
                                                ]
                                              )
                                            ]
                                            []
                                  }
                                , { name = "/play/test/some/module/add-money"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Union qualifiedUsMoneyUnion, Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                  , implementation =
                                        SoloImpl
                                            [ Word emptyRange "/play/test/some/module/into-cents"
                                            , Builtin emptyRange Builtin.StackSwap
                                            , Word emptyRange "/play/test/some/module/into-cents"
                                            , Builtin emptyRange Builtin.Plus
                                            ]
                                  }
                                , { name = "/play/test/some/module/quote-excuse"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "/play/test/some/module/Dollar" ]
                                                [ Type.Custom "/play/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl
                                            [ Word emptyRange "/play/test/some/module/dollar-value>"
                                            , WordRef emptyRange "quote:/play/test/some/module/quote-excuse/1"
                                            , Builtin emptyRange Builtin.Apply
                                            , Word emptyRange "/play/test/some/module/>Dollar"
                                            ]
                                  }
                                , { name = "quote:/play/test/some/module/quote-excuse/1"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.isQuoted
                                  , implementation =
                                        SoloImpl
                                            [ Integer emptyRange 2
                                            , Builtin emptyRange Builtin.Multiply
                                            ]
                                  }
                                , { name = "/play/test/some/module/>Dollar"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/play/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/play/test/some/module/Dollar" ]
                                  }
                                , { name = "/play/test/some/module/>Cent"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/play/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/play/test/some/module/Cent" ]
                                  }
                                , { name = "/play/test/some/module/>dollar-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Dollar", Type.Int ]
                                                [ Type.Custom "/play/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/play/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/play/test/some/module/>cent-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Cent", Type.Int ]
                                                [ Type.Custom "/play/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/play/test/some/module/Cent" "cent-value" ]
                                  }
                                , { name = "/play/test/some/module/dollar-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Dollar" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/play/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/play/test/some/module/cent-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Cent" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/play/test/some/module/Cent" "cent-value" ]
                                  }
                                ]
                        }
                in
                QualifierUtil.expectModuleOutput unqualifiedAst expectedAst
        , test "member types are qualified" <|
            \_ ->
                let
                    qualifiedUsMoneyUnion =
                        [ Type.Custom "/play/test/some/module/Dollar"
                        , Type.Custom "/play/test/some/module/Cent"
                        ]

                    unqualifiedAst =
                        { moduleDefinition = AST.emptyModuleDefinition
                        , types =
                            Dict.fromListBy AST.typeDefinitionName
                                [ AST.UnionTypeDef emptyRange
................................................................................
                        }
                            |> ParserUtil.addFunctionsForStructs

                    expectedAst =
                        { types =
                            Dict.fromListBy typeDefinitionName
                                [ UnionTypeDef
                                    "/play/test/some/module/USMoney"
                                    True
                                    emptyRange
                                    []
                                    qualifiedUsMoneyUnion
                                , CustomTypeDef "/play/test/some/module/Dollar"
                                    True
                                    emptyRange
                                    []
                                    [ ( "dollar-value", Type.Int ) ]
                                , CustomTypeDef "/play/test/some/module/Cent"
                                    True
                                    emptyRange
                                    []
                                    [ ( "cent-value", Type.Int ) ]
                                , CustomTypeDef "/play/test/some/module/Wallet"
                                    True
                                    emptyRange
                                    []
                                    [ ( "user-id", Type.Int )
                                    , ( "value", Type.Union qualifiedUsMoneyUnion )
                                    ]
                                ]
                        , words =
                            Dict.fromListBy .name
                                [ { name = "/play/test/some/module/>Dollar"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/play/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/play/test/some/module/Dollar" ]
                                  }
                                , { name = "/play/test/some/module/>Cent"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/play/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/play/test/some/module/Cent" ]
                                  }
                                , { name = "/play/test/some/module/>Wallet"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int, Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Custom "/play/test/some/module/Wallet" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/play/test/some/module/Wallet" ]
                                  }
                                , { name = "/play/test/some/module/>dollar-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Dollar", Type.Int ]
                                                [ Type.Custom "/play/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/play/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/play/test/some/module/>cent-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Cent", Type.Int ]
                                                [ Type.Custom "/play/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/play/test/some/module/Cent" "cent-value" ]
                                  }
                                , { name = "/play/test/some/module/>user-id"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Wallet", Type.Int ]
                                                [ Type.Custom "/play/test/some/module/Wallet" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/play/test/some/module/Wallet" "user-id" ]
                                  }
                                , { name = "/play/test/some/module/>value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Wallet", Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Custom "/play/test/some/module/Wallet" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/play/test/some/module/Wallet" "value" ]
                                  }
                                , { name = "/play/test/some/module/dollar-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Dollar" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/play/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/play/test/some/module/cent-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Cent" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/play/test/some/module/Cent" "cent-value" ]
                                  }
                                , { name = "/play/test/some/module/user-id>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/play/test/some/module/Wallet" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/play/test/some/module/Wallet" "user-id" ]
                                  }
                                , { name = "/play/test/some/module/value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/play/test/some/module/Wallet" ]
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/play/test/some/module/Wallet" "value" ]
                                  }
                                ]
                        }
                in
                QualifierUtil.expectModuleOutput unqualifiedAst expectedAst
        , test "Retrieve dependant modules" <|
            \_ ->
................................................................................
                            , "/robheghan/html/external/module"
                            , "/robheghan/html/external/types"
                            , "/robheghan/html/external/double"
                            , "/package/test/internal/alias"
                            , "/package/test/internal/types"
                            , "/package/test/internal/match"
                            , "/package/test/package/module"
                            , "/play/standard_library/core"
                            ]

                    actualRequiredModules =
                        requiredModules
                            { packageName = "package/test"
                            , ast = unqualifiedAst
                            , externalModules =
................................................................................
                                Dict.fromList
                                    [ ( "/list/of/names", "robheghan/dummy" )
                                    , ( "/some/ext", "robheghan/dummy" )
                                    , ( "/external/html", "robheghan/html" )
                                    , ( "/external/module", "robheghan/html" )
                                    , ( "/external/types", "robheghan/html" )
                                    , ( "/external/double", "robheghan/html" )
                                    , ( "/core", "play/standard_library" )
                                    ]
                            }
                in
                Expect.equal expectedRequiredModules actualRequiredModules
        , test "Reliance on standard_library/core only when standard_library is specified as externalModule" <|
            \_ ->
                let
................................................................................
                                    ]
                            }

                        inProgressAst =
                            { types = Dict.empty
                            , words =
                                Dict.fromList
                                    [ dummyWord "/play/standard_library/core/over" ]
                            }

                        result =
                            run
                                { packageName = ""
                                , modulePath = ""
                                , ast = unqualifiedAst
                                , externalModules =
                                    Dict.fromList
                                        [ ( "/core", "play/standard_library" ) ]
                                , inProgressAST = inProgressAst
                                }
                    in
                    case result of
                        Ok _ ->
                            Expect.pass

................................................................................
                                    ]
                            }

                        inProgressAst =
                            { types = Dict.empty
                            , words =
                                Dict.fromList
                                    [ dummyWord "/play/standard_library/core/over" ]
                            }

                        result =
                            run
                                { packageName = ""
                                , modulePath = ""
                                , ast = unqualifiedAst
                                , externalModules =
                                    Dict.fromList
                                        [ ( "/core", "play/standard_library" ) ]
                                , inProgressAST = inProgressAst
                                }
                    in
                    case result of
                        Ok _ ->
                            Expect.pass

                        Err errs ->
                            Expect.fail <| "Qualification failed with unexpected error: " ++ Debug.toString errs
            ]
        ]





>
|
|
|
|
|
|
|
<







 







|
|







 







|




|




|







|







|
|




|
|





|







|

|



|



|
|


|
|

|


|









|


|

|

|


|

|

|



|
|


|

|



|
|


|

|


|


|

|


|


|









|
|







 







|




|




|




|









|


|

|

|


|

|

|



|

|

|



|
|


|

|



|
|


|

|



|
|


|

|



|
|


|

|


|


|

|


|


|

|


|


|

|



|



|







 







|







 







|







 







|









|







 







|









|











1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
...
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
...
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
...
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
....
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
....
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
....
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
....
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
module Test.Qualifier exposing (..)

import Dict
import Dict.Extra as Dict
import Expect
import Set
import Stabel.Data.Builtin as Builtin
import Stabel.Data.Metadata as Metadata
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.Data.Type as Type
import Stabel.Parser as AST
import Stabel.Qualifier exposing (..)
import Stabel.Qualifier.Problem as Problem

import Test exposing (Test, describe, test)
import Test.Parser.Util as ParserUtil
import Test.Qualifier.Util as QualifierUtil


suite : Test
suite =
................................................................................
                            |> QualifierUtil.addFunctionsForStructs
                in
                QualifierUtil.expectOutput unqualifiedAst expectedAst
        , test "Name mangling" <|
            \_ ->
                let
                    qualifiedUsMoneyUnion =
                        [ Type.Custom "/stabel/test/some/module/Dollar"
                        , Type.Custom "/stabel/test/some/module/Cent"
                        ]

                    unqualifiedAst =
                        { moduleDefinition = AST.emptyModuleDefinition
                        , types =
                            Dict.fromListBy AST.typeDefinitionName
                                [ AST.UnionTypeDef emptyRange
................................................................................
                        }
                            |> ParserUtil.addFunctionsForStructs

                    expectedAst =
                        { types =
                            Dict.fromListBy typeDefinitionName
                                [ UnionTypeDef
                                    "/stabel/test/some/module/USMoney"
                                    True
                                    emptyRange
                                    []
                                    qualifiedUsMoneyUnion
                                , CustomTypeDef "/stabel/test/some/module/Dollar"
                                    True
                                    emptyRange
                                    []
                                    [ ( "dollar-value", Type.Int ) ]
                                , CustomTypeDef "/stabel/test/some/module/Cent"
                                    True
                                    emptyRange
                                    []
                                    [ ( "cent-value", Type.Int ) ]
                                ]
                        , words =
                            Dict.fromListBy .name
                                [ { name = "/stabel/test/some/module/into-cents"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatch emptyRange (Type.Custom "/stabel/test/some/module/Dollar") []
                                              , [ Word emptyRange "/stabel/test/some/module/dollar-value>"
                                                , Integer emptyRange 100
                                                , Builtin emptyRange Builtin.Multiply
                                                ]
                                              )
                                            , ( TypeMatch emptyRange (Type.Custom "/stabel/test/some/module/Cent") []
                                              , [ Word emptyRange "/stabel/test/some/module/cent-value>"
                                                ]
                                              )
                                            ]
                                            []
                                  }
                                , { name = "/stabel/test/some/module/add-money"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Union qualifiedUsMoneyUnion, Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                  , implementation =
                                        SoloImpl
                                            [ Word emptyRange "/stabel/test/some/module/into-cents"
                                            , Builtin emptyRange Builtin.StackSwap
                                            , Word emptyRange "/stabel/test/some/module/into-cents"
                                            , Builtin emptyRange Builtin.Plus
                                            ]
                                  }
                                , { name = "/stabel/test/some/module/quote-excuse"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withType
                                                [ Type.Custom "/stabel/test/some/module/Dollar" ]
                                                [ Type.Custom "/stabel/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl
                                            [ Word emptyRange "/stabel/test/some/module/dollar-value>"
                                            , WordRef emptyRange "quote:/stabel/test/some/module/quote-excuse/1"
                                            , Builtin emptyRange Builtin.Apply
                                            , Word emptyRange "/stabel/test/some/module/>Dollar"
                                            ]
                                  }
                                , { name = "quote:/stabel/test/some/module/quote-excuse/1"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.isQuoted
                                  , implementation =
                                        SoloImpl
                                            [ Integer emptyRange 2
                                            , Builtin emptyRange Builtin.Multiply
                                            ]
                                  }
                                , { name = "/stabel/test/some/module/>Dollar"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/stabel/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/stabel/test/some/module/Dollar" ]
                                  }
                                , { name = "/stabel/test/some/module/>Cent"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/stabel/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/stabel/test/some/module/Cent" ]
                                  }
                                , { name = "/stabel/test/some/module/>dollar-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Dollar", Type.Int ]
                                                [ Type.Custom "/stabel/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/stabel/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/stabel/test/some/module/>cent-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Cent", Type.Int ]
                                                [ Type.Custom "/stabel/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/stabel/test/some/module/Cent" "cent-value" ]
                                  }
                                , { name = "/stabel/test/some/module/dollar-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/stabel/test/some/module/Dollar" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/stabel/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/stabel/test/some/module/cent-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/stabel/test/some/module/Cent" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/stabel/test/some/module/Cent" "cent-value" ]
                                  }
                                ]
                        }
                in
                QualifierUtil.expectModuleOutput unqualifiedAst expectedAst
        , test "member types are qualified" <|
            \_ ->
                let
                    qualifiedUsMoneyUnion =
                        [ Type.Custom "/stabel/test/some/module/Dollar"
                        , Type.Custom "/stabel/test/some/module/Cent"
                        ]

                    unqualifiedAst =
                        { moduleDefinition = AST.emptyModuleDefinition
                        , types =
                            Dict.fromListBy AST.typeDefinitionName
                                [ AST.UnionTypeDef emptyRange
................................................................................
                        }
                            |> ParserUtil.addFunctionsForStructs

                    expectedAst =
                        { types =
                            Dict.fromListBy typeDefinitionName
                                [ UnionTypeDef
                                    "/stabel/test/some/module/USMoney"
                                    True
                                    emptyRange
                                    []
                                    qualifiedUsMoneyUnion
                                , CustomTypeDef "/stabel/test/some/module/Dollar"
                                    True
                                    emptyRange
                                    []
                                    [ ( "dollar-value", Type.Int ) ]
                                , CustomTypeDef "/stabel/test/some/module/Cent"
                                    True
                                    emptyRange
                                    []
                                    [ ( "cent-value", Type.Int ) ]
                                , CustomTypeDef "/stabel/test/some/module/Wallet"
                                    True
                                    emptyRange
                                    []
                                    [ ( "user-id", Type.Int )
                                    , ( "value", Type.Union qualifiedUsMoneyUnion )
                                    ]
                                ]
                        , words =
                            Dict.fromListBy .name
                                [ { name = "/stabel/test/some/module/>Dollar"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/stabel/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/stabel/test/some/module/Dollar" ]
                                  }
                                , { name = "/stabel/test/some/module/>Cent"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int ] [ Type.Custom "/stabel/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/stabel/test/some/module/Cent" ]
                                  }
                                , { name = "/stabel/test/some/module/>Wallet"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Int, Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Custom "/stabel/test/some/module/Wallet" ]
                                  , implementation =
                                        SoloImpl [ ConstructType "/stabel/test/some/module/Wallet" ]
                                  }
                                , { name = "/stabel/test/some/module/>dollar-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Dollar", Type.Int ]
                                                [ Type.Custom "/stabel/test/some/module/Dollar" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/stabel/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/stabel/test/some/module/>cent-value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Cent", Type.Int ]
                                                [ Type.Custom "/stabel/test/some/module/Cent" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/stabel/test/some/module/Cent" "cent-value" ]
                                  }
                                , { name = "/stabel/test/some/module/>user-id"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Wallet", Type.Int ]
                                                [ Type.Custom "/stabel/test/some/module/Wallet" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/stabel/test/some/module/Wallet" "user-id" ]
                                  }
                                , { name = "/stabel/test/some/module/>value"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Wallet", Type.Union qualifiedUsMoneyUnion ]
                                                [ Type.Custom "/stabel/test/some/module/Wallet" ]
                                  , implementation =
                                        SoloImpl
                                            [ SetMember "/stabel/test/some/module/Wallet" "value" ]
                                  }
                                , { name = "/stabel/test/some/module/dollar-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/stabel/test/some/module/Dollar" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/stabel/test/some/module/Dollar" "dollar-value" ]
                                  }
                                , { name = "/stabel/test/some/module/cent-value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/stabel/test/some/module/Cent" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/stabel/test/some/module/Cent" "cent-value" ]
                                  }
                                , { name = "/stabel/test/some/module/user-id>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType [ Type.Custom "/stabel/test/some/module/Wallet" ] [ Type.Int ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/stabel/test/some/module/Wallet" "user-id" ]
                                  }
                                , { name = "/stabel/test/some/module/value>"
                                  , metadata =
                                        Metadata.default
                                            |> Metadata.withVerifiedType
                                                [ Type.Custom "/stabel/test/some/module/Wallet" ]
                                                [ Type.Union qualifiedUsMoneyUnion ]
                                  , implementation =
                                        SoloImpl
                                            [ GetMember "/stabel/test/some/module/Wallet" "value" ]
                                  }
                                ]
                        }
                in
                QualifierUtil.expectModuleOutput unqualifiedAst expectedAst
        , test "Retrieve dependant modules" <|
            \_ ->
................................................................................
                            , "/robheghan/html/external/module"
                            , "/robheghan/html/external/types"
                            , "/robheghan/html/external/double"
                            , "/package/test/internal/alias"
                            , "/package/test/internal/types"
                            , "/package/test/internal/match"
                            , "/package/test/package/module"
                            , "/stabel/standard_library/core"
                            ]

                    actualRequiredModules =
                        requiredModules
                            { packageName = "package/test"
                            , ast = unqualifiedAst
                            , externalModules =
................................................................................
                                Dict.fromList
                                    [ ( "/list/of/names", "robheghan/dummy" )
                                    , ( "/some/ext", "robheghan/dummy" )
                                    , ( "/external/html", "robheghan/html" )
                                    , ( "/external/module", "robheghan/html" )
                                    , ( "/external/types", "robheghan/html" )
                                    , ( "/external/double", "robheghan/html" )
                                    , ( "/core", "stabel/standard_library" )
                                    ]
                            }
                in
                Expect.equal expectedRequiredModules actualRequiredModules
        , test "Reliance on standard_library/core only when standard_library is specified as externalModule" <|
            \_ ->
                let
................................................................................
                                    ]
                            }

                        inProgressAst =
                            { types = Dict.empty
                            , words =
                                Dict.fromList
                                    [ dummyWord "/stabel/standard_library/core/over" ]
                            }

                        result =
                            run
                                { packageName = ""
                                , modulePath = ""
                                , ast = unqualifiedAst
                                , externalModules =
                                    Dict.fromList
                                        [ ( "/core", "stabel/standard_library" ) ]
                                , inProgressAST = inProgressAst
                                }
                    in
                    case result of
                        Ok _ ->
                            Expect.pass

................................................................................
                                    ]
                            }

                        inProgressAst =
                            { types = Dict.empty
                            , words =
                                Dict.fromList
                                    [ dummyWord "/stabel/standard_library/core/over" ]
                            }

                        result =
                            run
                                { packageName = ""
                                , modulePath = ""
                                , ast = unqualifiedAst
                                , externalModules =
                                    Dict.fromList
                                        [ ( "/core", "stabel/standard_library" ) ]
                                , inProgressAST = inProgressAst
                                }
                    in
                    case result of
                        Ok _ ->
                            Expect.pass

                        Err errs ->
                            Expect.fail <| "Qualification failed with unexpected error: " ++ Debug.toString errs
            ]
        ]

Modified tests/Test/Qualifier/Error.elm from [0f9091b125] to [afea07fa69].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Test.Qualifier.Error exposing (..)

import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Play.Data.Metadata as Metadata
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type
import Play.Parser as AST
import Play.Qualifier exposing (..)
import Play.Qualifier.Problem exposing (Problem(..))
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "Qualifier errors"
        [ describe "No such reference" <|





|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Test.Qualifier.Error exposing (..)

import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Stabel.Data.Metadata as Metadata
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.Data.Type as Type
import Stabel.Parser as AST
import Stabel.Qualifier exposing (..)
import Stabel.Qualifier.Problem exposing (Problem(..))
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "Qualifier errors"
        [ describe "No such reference" <|

Modified tests/Test/Qualifier/Util.elm from [d1d2da2384] to [159e7155db].

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    , expectOutput
    , stripLocations
    )

import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Play.Data.Metadata as Metadata
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type exposing (Type)
import Play.Parser as Parser
import Play.Qualifier as AST
    exposing
        ( AST
        , Node(..)
        , TypeDefinition
        , TypeMatch(..)
        , TypeMatchValue(..)
        , WordDefinition
................................................................................


expectModuleOutput : Parser.AST -> AST -> Expectation
expectModuleOutput parserAst expectedAst =
    let
        result =
            AST.run
                { packageName = "play/test"
                , modulePath = "some/module"
                , ast = parserAst
                , externalModules = Dict.empty
                , inProgressAST = emptyAst
                }
    in
    case result of







|
|
|
|
|







 







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    , expectOutput
    , stripLocations
    )

import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Stabel.Data.Metadata as Metadata
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.Data.Type as Type exposing (Type)
import Stabel.Parser as Parser
import Stabel.Qualifier as AST
    exposing
        ( AST
        , Node(..)
        , TypeDefinition
        , TypeMatch(..)
        , TypeMatchValue(..)
        , WordDefinition
................................................................................


expectModuleOutput : Parser.AST -> AST -> Expectation
expectModuleOutput parserAst expectedAst =
    let
        result =
            AST.run
                { packageName = "stabel/test"
                , modulePath = "some/module"
                , ast = parserAst
                , externalModules = Dict.empty
                , inProgressAST = emptyAst
                }
    in
    case result of

Modified tests/Test/StabelExpect.elm from [1b415049a2] to [f6a5e13a96].

1
2
3
4
5
6
7
8
module Test.PlayExpect exposing
    ( allEqual
    , allErr
    , allOk
    )

import Expect

|







1
2
3
4
5
6
7
8
module Test.StabelExpect exposing
    ( allEqual
    , allErr
    , allOk
    )

import Expect

Modified tests/Test/TypeChecker.elm from [5cf7f1ff07] to [09b3804701].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Test.TypeChecker exposing (..)

import Dict
import Dict.Extra as Dict
import Expect
import Play.Data.Builtin as Builtin
import Play.Data.Metadata as Metadata
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type
import Play.Qualifier as QAST
import Play.TypeChecker exposing (..)
import Play.TypeChecker.Problem as Problem
import Test exposing (Test, describe, test)
import Test.Qualifier.Util as QualifierUtil


suite : Test
suite =
    describe "TypeChecker"





|
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Test.TypeChecker exposing (..)

import Dict
import Dict.Extra as Dict
import Expect
import Stabel.Data.Builtin as Builtin
import Stabel.Data.Metadata as Metadata
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.Data.Type as Type
import Stabel.Qualifier as QAST
import Stabel.TypeChecker exposing (..)
import Stabel.TypeChecker.Problem as Problem
import Test exposing (Test, describe, test)
import Test.Qualifier.Util as QualifierUtil


suite : Test
suite =
    describe "TypeChecker"

Modified tests/Test/TypeChecker/Error.elm from [8ad155b434] to [26f4b80df6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Test.TypeChecker.Error exposing (..)

import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Play.Data.Builtin as Builtin
import Play.Data.Metadata as Metadata
import Play.Data.SourceLocation exposing (emptyRange)
import Play.Data.Type as Type
import Play.Qualifier exposing (..)
import Play.TypeChecker as TypeChecker
import Play.TypeChecker.Problem as Problem
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "TypeChecker errors"
        [ test "Undeclared generic" <|





|
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Test.TypeChecker.Error exposing (..)

import Dict
import Dict.Extra as Dict
import Expect exposing (Expectation)
import Stabel.Data.Builtin as Builtin
import Stabel.Data.Metadata as Metadata
import Stabel.Data.SourceLocation exposing (emptyRange)
import Stabel.Data.Type as Type
import Stabel.Qualifier exposing (..)
import Stabel.TypeChecker as TypeChecker
import Stabel.TypeChecker.Problem as Problem
import Test exposing (Test, describe, test)


suite : Test
suite =
    describe "TypeChecker errors"
        [ test "Undeclared generic" <|