From 1ee2822070a4afe7904ea146cfc99917f47a7d8b Mon Sep 17 00:00:00 2001 From: Kindson The Genius <35315234+KindsonTheGenius@users.noreply.github.com> Date: Wed, 19 Apr 2023 06:19:49 +0000 Subject: [PATCH 1/5] Syncing operations - tracking file deletion - 1 --- docs/Json-schema-bakend-config-processing.md | 6 ++++++ docs/configuration-management.md | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 docs/Json-schema-bakend-config-processing.md create mode 100644 docs/configuration-management.md diff --git a/docs/Json-schema-bakend-config-processing.md b/docs/Json-schema-bakend-config-processing.md new file mode 100644 index 000000000..6a5717bb9 --- /dev/null +++ b/docs/Json-schema-bakend-config-processing.md @@ -0,0 +1,6 @@ +# Json Schema Backend Configuration +This document outlines both the high-level and th detailed approah to +managing backend configuration. + +## Initial Configuration Processing +For the first part \ No newline at end of file diff --git a/docs/configuration-management.md b/docs/configuration-management.md new file mode 100644 index 000000000..316d319d3 --- /dev/null +++ b/docs/configuration-management.md @@ -0,0 +1,9 @@ +# Configuration Management +This document provides a description of the configuration management strategy on Morphir. + + + + +## Backend Configuration +Json Sce + From 6980c7d40999376c94edb5723f32ab8fd7b7ad3a Mon Sep 17 00:00:00 2001 From: Kindson The Genius <35315234+KindsonTheGenius@users.noreply.github.com> Date: Wed, 19 Apr 2023 06:23:25 +0000 Subject: [PATCH 2/5] Syncing operations - tracking file deletions - 1 --- docs/Json-schema-bakend-config-processing.md | 6 ------ docs/configuration-management.md | 9 --------- 2 files changed, 15 deletions(-) delete mode 100644 docs/Json-schema-bakend-config-processing.md delete mode 100644 docs/configuration-management.md diff --git a/docs/Json-schema-bakend-config-processing.md b/docs/Json-schema-bakend-config-processing.md deleted file mode 100644 index 6a5717bb9..000000000 --- a/docs/Json-schema-bakend-config-processing.md +++ /dev/null @@ -1,6 +0,0 @@ -# Json Schema Backend Configuration -This document outlines both the high-level and th detailed approah to -managing backend configuration. - -## Initial Configuration Processing -For the first part \ No newline at end of file diff --git a/docs/configuration-management.md b/docs/configuration-management.md deleted file mode 100644 index 316d319d3..000000000 --- a/docs/configuration-management.md +++ /dev/null @@ -1,9 +0,0 @@ -# Configuration Management -This document provides a description of the configuration management strategy on Morphir. - - - - -## Backend Configuration -Json Sce - From d5876495244aedee1d32519e59d09ff9a2619f94 Mon Sep 17 00:00:00 2001 From: Kindson The Genius <35315234+KindsonTheGenius@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:09:32 +0000 Subject: [PATCH 3/5] Standardized file names to Kebab case --- README.md | 8 +- ...on_modeling.md => application-modeling.md} | 0 docs/background.md | 2 +- docs/cadl-doc.md | 22 +++--- ...{CODE_OF_CONDUCT.md => code-of-conduct.md} | 0 ...nd_line_tools.md => command-line-tools.md} | 0 docs/{CONTRIBUTING.md => contributing.md} | 0 ...tom Attributes.md => custom-attributes.md} | 0 ...ers guide.md => decorators-users-guide.md} | 0 docs/{dev_bots.md => dev-bots.md} | 0 docs/developer-guide-index.md | 74 +++++++++---------- docs/{editor_setup.md => editor-setup.md} | 0 docs/index3.md | 2 +- docs/{Insight-README.md => insight-readme.md} | 0 ...and_usage.md => installation-and-usage.md} | 0 docs/json-schema-backend-testplan.md | 6 +- docs/json-schema-enabled developers guide.md | 2 +- docs/json-schema-mappings.md | 58 ++++++++------- ...phir_community.md => morphir-community.md} | 0 ...tation.html => morphir-documentation.html} | 0 ...egtech_modeling.md => regtech-modeling.md} | 0 ...-Json-Backend.md => scala-json-backend.md} | 0 ...-README.md => testing-framework-readme.md} | 0 docs/user-guide-readme.md | 10 +-- docs/{whats_it_about.md => whats-it-about.md} | 0 ...mming.md => why-functional-programming.md} | 0 ...-Elm.md => working-with-results-in-elm.md} | 63 ++++++++-------- 27 files changed, 124 insertions(+), 123 deletions(-) rename docs/{application_modeling.md => application-modeling.md} (100%) rename docs/{CODE_OF_CONDUCT.md => code-of-conduct.md} (100%) rename docs/{command_line_tools.md => command-line-tools.md} (100%) rename docs/{CONTRIBUTING.md => contributing.md} (100%) rename docs/{Custom Attributes.md => custom-attributes.md} (100%) rename docs/{decorators users guide.md => decorators-users-guide.md} (100%) rename docs/{dev_bots.md => dev-bots.md} (100%) rename docs/{editor_setup.md => editor-setup.md} (100%) rename docs/{Insight-README.md => insight-readme.md} (100%) rename docs/{installation_and_usage.md => installation-and-usage.md} (100%) rename docs/{morphir_community.md => morphir-community.md} (100%) rename docs/{morphirDocumentation.html => morphir-documentation.html} (100%) rename docs/{regtech_modeling.md => regtech-modeling.md} (100%) rename docs/{Scala-Json-Backend.md => scala-json-backend.md} (100%) rename docs/{TestingFramework-README.md => testing-framework-readme.md} (100%) rename docs/{whats_it_about.md => whats-it-about.md} (100%) rename docs/{why_functional_programming.md => why-functional-programming.md} (100%) rename docs/{Working-With-Results-in-Elm.md => working-with-results-in-elm.md} (86%) diff --git a/README.md b/README.md index 0508b8864..b66f81f33 100644 --- a/README.md +++ b/README.md @@ -72,10 +72,10 @@ Morphir consists of a few projects based on the features they provide. | Introduction & Background | Using Morphir | Applicability | | :------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- | | [Resource Centre](https://resources.finos.org/morphir/) | [What Makes a Good Model](./docs/what-makes-a-good-domain-model.md) | [Sharing Business Logic Across Application Boundaries](./docs/shared_logic_modeling.md) | -| [Background](./docs/background.md) | [Development Automation (Dev Bots)](./docs/dev_bots.md) | [Regulatory Technology](./docs/regtech_modeling.md) | -| [Community](./docs/morphir_community.md) | [Modeling an Application](./docs/application_modeling.md) | | -| [What's it all about?](./docs/whats_it_about.md) | [Modeling Decision Tables](https://github.com/finos/morphir-examples/tree/master/src/Morphir/Sample/Rules) | | -| [Why we use Functional Programming?](./docs/why_functional_programming.md) | [Modeling for database developers](docs/modeling-for-database-developers.md) | +| [Background](./docs/background.md) | [Development Automation (Dev Bots)](./docs/dev-bots.md) | [Regulatory Technology](./docs/regtech-modeling.md) | +| [Community](./docs/morphir-community.md) | [Modeling an Application](./docs/application-modeling.md) | | +| [What's it all about?](./docs/whats-it-about.md) | [Modeling Decision Tables](https://github.com/finos/morphir-examples/tree/master/src/Morphir/Sample/Rules) | | +| [Why we use Functional Programming?](./docs/why-functional-programming.md) | [Modeling for database developers](docs/modeling-for-database-developers.md) | ## Roadmap diff --git a/docs/application_modeling.md b/docs/application-modeling.md similarity index 100% rename from docs/application_modeling.md rename to docs/application-modeling.md diff --git a/docs/background.md b/docs/background.md index 8ef1c577c..624ae7c35 100644 --- a/docs/background.md +++ b/docs/background.md @@ -68,7 +68,7 @@ that shape is decided, a great deal of the actual coding is very repetative and practices and team standards and you get a lot of boilerplate code that can be automated for faster production with fewer errors. Morphir relies heavily on such automation, which we call Dev Bots. As with any automation, smart use can lead to drastic efficiency improvements, like taking seconds to generate what a developer would take days to -produce. Check out the [Dev Bot post](dev_bots) for more information on this topic. +produce. Check out the [Dev Bot post](dev-bots) for more information on this topic. ### Eliminating Rewrites diff --git a/docs/cadl-doc.md b/docs/cadl-doc.md index b67410105..efed7202c 100644 --- a/docs/cadl-doc.md +++ b/docs/cadl-doc.md @@ -198,7 +198,7 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ } ``` -3. In a Scenario where a field type is `maybe` of another `maybe` type, it is represented as an `optional field` of the `union` type.
+3. In a Scenario where a field type is `maybe` of another `maybe` type, it is represented as an `optional field` of the `union` type. Elm: ```elm @@ -216,7 +216,7 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ baz ?: string | null } ``` - _Note:_
+ _Note:_ \ _In the scenario of multiple `maybe` type for a field in a model, it shall be represented as just the type or null_ ### Collection Types @@ -329,7 +329,7 @@ model FooBarBaz { ``` ### [Custom Types](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) -##### [General Case]() +##### [General Case](#) A `custom` type in morphir is a user defined type used to represent a business term or type. This concept is not directly supported in CADL but can be achieved as tagged `union` of Tuples, where the first element represents type name in string, followed by its arguments. @@ -345,7 +345,7 @@ Cadl: ```cadl alias FooBarBaz = ["Foo", int64] | ["Bar", string] | "Baz"; ``` -##### [Special Case]() +##### [Special Case](#) A `custom` type in morphir whose constructors have no arguments would be represented in CADL as an `enum` type. Elm: @@ -369,13 +369,13 @@ enum Currency { --- -|
| CADL Type
| Morphir Type
| Comment
| -|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [Namespaces](https://microsoft.github.io/cadl/language-basics/namespaces) | `namespace Petstore` | `module PetStore exposing (...)` | Namespaces in CADL map to [Modules](https://package.elm-lang.org/packages/Morgan-Stanley/morphir-elm/latest/Morphir-IR-Module) in Morphir | -| [Models](https://microsoft.github.io/cadl/language-basics/models) | `model Dog { name: string; age: number}` | `type alias Dog = { name: string, age: int}` | Models in CADL map to [Records](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Value#record) in Morphir | -| [Enums](https://microsoft.github.io/cadl/language-basics/enums) | `enum Direction {East; West; North; South}` | `type Direction `
`= East` | `West` | `North` | `South` | Enums in CADL map to [Union Types](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) in Mophir | +|
| CADL Type
| Morphir Type
| Comment
| +|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [Namespaces](https://microsoft.github.io/cadl/language-basics/namespaces) | `namespace Petstore` | `module PetStore exposing (...)` | Namespaces in CADL map to [Modules](https://package.elm-lang.org/packages/Morgan-Stanley/morphir-elm/latest/Morphir-IR-Module) in Morphir | +| [Models](https://microsoft.github.io/cadl/language-basics/models) | `model Dog { name: string; age: number}` | `type alias Dog = { name: string, age: int}` | Models in CADL map to [Records](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Value#record) in Morphir | +| [Enums](https://microsoft.github.io/cadl/language-basics/enums) | `enum Direction {East; West; North; South}` | `type Direction `
`= East` | `West` | `North` | `South` | Enums in CADL map to [Union Types](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) in Mophir | | [Union Type](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) ||| -| | - Unnamed Union
`alias Breed = Breagle` | `GermanShepherd` | `GoldenRetriever`
- Named Union
`union Breed {`
  `beagle: Beagle,`
  `shepherd: GermanShepherd.`
  `retiever: GoldenRetriever`
`}` |`type Breed`
  `= Beagle Beagle`
    | `Shepherd GermanShepherd `
    | `Retriever GoldenRetriever`| Named unions in CADL maps to a Custom Type with a `type parameter` in Morphir. Any other detail of the type is captured in Morphir's `Decorators(Custom Attributes).`
NB: unnamed Unions are currently not supported in morphir | +| | - Unnamed Union
`alias Breed = Breagle` | `GermanShepherd` | `GoldenRetriever`
- Named Union
`union Breed {`
  `beagle: Beagle,`
  `shepherd: GermanShepherd.`
  `retiever: GoldenRetriever`
`}` | `type Breed`
  `= Beagle Beagle`
    | `Shepherd GermanShepherd `
    | `Retriever GoldenRetriever` | Named unions in CADL maps to a Custom Type with a `type parameter` in Morphir. Any other detail of the type is captured in Morphir's `Decorators(Custom Attributes).`
NB: unnamed Unions are currently not supported in morphir | ## [Type Relations](https://microsoft.github.io/cadl/language-basics/type-relations) @@ -384,7 +384,7 @@ enum Currency { Boolean in CADL, maps to [`bool`](https://package.elm-lang.org/packages/elm/core/latest/Basics#Bool), a `true` or `false` value in Morphir. ##### Integer -In Morphir, this maps to the type [`int`.](https://package.elm-lang.org/packages/elm/core/latest/Basics#Int) The `integer` type assignment is valid CADL, but
+In Morphir, this maps to the type [`int`.](https://package.elm-lang.org/packages/elm/core/latest/Basics#Int) The `integer` type assignment is valid CADL, but \ Things to note :: 1. When dealing with emitters such as OpenApiSpec(OAS) it defaults to an object. To obtain an actual int value, specify a subtype `int64`. diff --git a/docs/CODE_OF_CONDUCT.md b/docs/code-of-conduct.md similarity index 100% rename from docs/CODE_OF_CONDUCT.md rename to docs/code-of-conduct.md diff --git a/docs/command_line_tools.md b/docs/command-line-tools.md similarity index 100% rename from docs/command_line_tools.md rename to docs/command-line-tools.md diff --git a/docs/CONTRIBUTING.md b/docs/contributing.md similarity index 100% rename from docs/CONTRIBUTING.md rename to docs/contributing.md diff --git a/docs/Custom Attributes.md b/docs/custom-attributes.md similarity index 100% rename from docs/Custom Attributes.md rename to docs/custom-attributes.md diff --git a/docs/decorators users guide.md b/docs/decorators-users-guide.md similarity index 100% rename from docs/decorators users guide.md rename to docs/decorators-users-guide.md diff --git a/docs/dev_bots.md b/docs/dev-bots.md similarity index 100% rename from docs/dev_bots.md rename to docs/dev-bots.md diff --git a/docs/developer-guide-index.md b/docs/developer-guide-index.md index a5b4b65e4..59a919191 100644 --- a/docs/developer-guide-index.md +++ b/docs/developer-guide-index.md @@ -8,48 +8,48 @@ Finally, it provides a step by step walk-throughs on how various Morphir compone 2. Existing team members intending to improve their abilities on Language Design concepts ##Content -1. [Getting Started with Morphir](README.md)
+1. [Getting Started with Morphir](README.md) 2. [Overview of Morphir](#) -3. [The Morphir Architecture](#)
-4. [The Morphir SDK](#)
-5. [Morphir Commands Processing](Morphir-elm Commands Processing)
- 1. [morphir-elm make](#)
- 2. [morphir-elm gen](#)
- 3. [morphir-elm test](#)
- 4. [morphir-elm develop](#)
-6. [Interoperability With JavaScript](#)
-7. [Testing Framework](#)
+3. [The Morphir Architecture](#) +4. [The Morphir SDK](#) +5. [Morphir Commands Processing](Morphir-elm Commands Processing) + 1. [morphir-elm make](#) + 2. [morphir-elm gen](#) + 3. [morphir-elm test](#) + 4. [morphir-elm develop](#) +6. [Interoperability With JavaScript](#) +7. [Testing Framework](#) 1. [CSV testing guide ](spark-testing-framework.md) -8. [The Morphir IR](#)
- 1. [Overview of the Morphir IR](#)
- 2. [Distribution](#)
- 3. [Package](#)
- 4. [Module](#)
- 5. [Types](#)
- 6. [Values](#)
- 7. [Names](#)
-9. [The Morphir Frontends](#)
- 1. [Elm Frontend](#)
- 2. [Elm Incremental Frontend](#)
-10. [The Morphir Backends](#)
+8. [The Morphir IR](#) + 1. [Overview of the Morphir IR](#) + 2. [Distribution](#) + 3. [Package](#) + 4. [Module](#) + 5. [Types](#) + 6. [Values](#) + 7. [Names](#) +9. [The Morphir Frontends](#) + 1. [Elm Frontend](#) + 2. [Elm Incremental Frontend](#) +10. [The Morphir Backends](#) 1. [Scala Backend](scala-backend.md) 2. [Spark Backend](spark-backend.md) 3. [Relational IR Backends](relational-backend.md) 4. [Scala Json Codecs Backend](scala-backend.md) 5. [Json Schema Backend](json-schema-mappings.md) -11. [Working with CODECS](#)
- 1. [Introduction to Encoding/Decoding](#)
- 2. [JSON Decoder Building Blocks](#)
- 3. [Combining Decoders](#)
- 4. [JSON Decode Pipeline](#)
- 5. [Writing Encoders and Decoders in Elm](#)
- 6. [Standard Codecs in Morphir](#)
-12. [NPM and Elm Packages](#)
-13. [Introduction to Combinator Parsing in Scala](#)
- 1. [Overview of Combinator Parsing](#)
- 2. [Parser or Basic Arithmetic Expression](#)
- 3. [Implementing Parsers in Scala](#)
- 4. [Regular Expressions Parser](#)
- 5. [JSON Parser](#)
- 6. [Low-Level Pull Parser API](#)
+11. [Working with CODECS](#) + 1. [Introduction to Encoding/Decoding](#) + 2. [JSON Decoder Building Blocks](#) + 3. [Combining Decoders](#) + 4. [JSON Decode Pipeline](#) + 5. [Writing Encoders and Decoders in Elm](#) + 6. [Standard Codecs in Morphir](#) +12. [NPM and Elm Packages](#) +13. [Introduction to Combinator Parsing in Scala](#) + 1. [Overview of Combinator Parsing](#) + 2. [Parser or Basic Arithmetic Expression](#) + 3. [Implementing Parsers in Scala](#) + 4. [Regular Expressions Parser](#) + 5. [JSON Parser](#) + 6. [Low-Level Pull Parser API](#) diff --git a/docs/editor_setup.md b/docs/editor-setup.md similarity index 100% rename from docs/editor_setup.md rename to docs/editor-setup.md diff --git a/docs/index3.md b/docs/index3.md index 7f751fc0b..d59e9553f 100644 --- a/docs/index3.md +++ b/docs/index3.md @@ -22,7 +22,7 @@ This has been impactful enough that we want to bring it to the open-source commu Your application has a soul - it's reason for existing. It might be embodied in calculations, business rules, and other logic. Collectively these are your application's most important assets. You need to protect these assets. You also want to do useful things with it. -For starters, you definately want it to **[function correctly](why_functional_programming)**. Ideally, it could do that **[across different technologies and platforms](work_across_languages_and_platforms)**. In addition, you also want to **[share the knowledge](shared_logic_modeling)** to your application's stakeholders. This provides transparency and gives them **[confidence](build_confidence)** in what you're delivering. It also makes supporting and learning about your application easier. The world is changing fast, so you want all of these characteristics while **[delivering quickly and efficiently](dev_bots)**. +For starters, you definately want it to **[function correctly](why-functional-programming)**. Ideally, it could do that **[across different technologies and platforms](work_across_languages_and_platforms)**. In addition, you also want to **[share the knowledge](shared_logic_modeling)** to your application's stakeholders. This provides transparency and gives them **[confidence](build_confidence)** in what you're delivering. It also makes supporting and learning about your application easier. The world is changing fast, so you want all of these characteristics while **[delivering quickly and efficiently](dev-bots)**. This is where Morphir comes in. **Morphir treats logic like data**. This simple concept makes it possible to do all of these things and more. Morphir makes development better. To learn more ... diff --git a/docs/Insight-README.md b/docs/insight-readme.md similarity index 100% rename from docs/Insight-README.md rename to docs/insight-readme.md diff --git a/docs/installation_and_usage.md b/docs/installation-and-usage.md similarity index 100% rename from docs/installation_and_usage.md rename to docs/installation-and-usage.md diff --git a/docs/json-schema-backend-testplan.md b/docs/json-schema-backend-testplan.md index fefb46612..b49810301 100644 --- a/docs/json-schema-backend-testplan.md +++ b/docs/json-schema-backend-testplan.md @@ -9,8 +9,8 @@ This document speficies the testing strategy for the Json Schema backend. The unit test aims to test all the ```elm mapType()``` and the ```elm mapTypeDefinition()``` methods defined in the [Json Schema Backend]('../../../src/JsonSchema/Backeng.elm') -Test for each module would be defined in a file with the name patter Tests.elm. -For example:
+Test for each module would be defined in a file with the name pattern <ModuleName> Tests.elm. +For example \ Test for BasicTypes would be defined in a file named BasicTypesTests.elm ### 2. System Test (JavaScript) @@ -21,7 +21,7 @@ Therefore this would be implemented using the Jest on the JavaScript end. The [Ajv Json Schema Validator](https://www.npmjs.com/package/ajv?activeTab=readme) library would be used for validation. We also need to ensure the validity of each subschema -in the generated Json output.
+in the generated Json output.\ This tests are defined in the [json-schema.test.js](../../../tests-integration/json-schema/test/json-schema.test.js) file. This tests are performed in tandem with the Accetance Tests diff --git a/docs/json-schema-enabled developers guide.md b/docs/json-schema-enabled developers guide.md index e98ddcff3..294b298ee 100644 --- a/docs/json-schema-enabled developers guide.md +++ b/docs/json-schema-enabled developers guide.md @@ -27,7 +27,7 @@ and the CustomAttributesDetails * displayName - String display name of the custom attribute * entryPoint - FQName or ModuleName being decorated * iR - Distribution for the custom attribute IR - * data - the custom attribute dictionary (content of the file) + * data - the custom attribute dictionary (content of the <unique-id.json> file) ## Setting Up json-schema-enabled for a New Project This section explains how the json-schema-enabled decorator is setup for a Morphir project diff --git a/docs/json-schema-mappings.md b/docs/json-schema-mappings.md index 42669a88b..bc08f485d 100644 --- a/docs/json-schema-mappings.md +++ b/docs/json-schema-mappings.md @@ -33,41 +33,43 @@ Run the ```elm morphir-elm make ``` command to generate an IR * Step 2 Run the ```elm morphir-elm gen -t JsonSchema``` to generate the Json Schema -**Note** - The generated schema is named .json by default. But you can specify the filename +**Note** - The generated schema is named `.json` by default. But you can specify the filename optionally for the schema using the -f flag. +
+

Next, we will get into some specific cases that may need further explanation. The rest of the explains how each Morphir type maps to the Json Schema Types. -1. ### [ SDK Types](#sdk-types)
- #### [1.1. Basic types](#basic-types)
+1. ### [ SDK Types](#sdk-types) + #### [1.1. Basic types](#basic-types) [1.1.1. Bool ](#bool)
- [1.1.2. Int ](#int)
- [1.1.3. Float ](#float)
- [1.1.4. Char ](#char)
- [1.1.5. String ](#string)
- #### [1.2. Advanced types](#advanced-types)
- [1.2.1. Decimal](#decimal)
- [1.2.2. LocalDate ](#localdate)
- [1.2.3. LocalTime](#localtime)
- [1.2.4. Month](#month)
- #### [1.3. Optional values](#optional-values)
+ [1.1.2. Int ](#int)\ + [1.1.3. Float ](#float)\ + [1.1.4. Char ](#char)\ + [1.1.5. String ](#string)\ + #### [1.2. Advanced types](#advanced-types) \ + [1.2.1. Decimal](#decimal)\ + [1.2.2. LocalDate ](#localdate)\ + [1.2.3. LocalTime](#localtime)\ + [1.2.4. Month](#month)\ + #### [1.3. Optional values](#optional-values)\ #### [1.4. Collections](#collections) - [1.4.1. List ](#list)
- [1.4.2. Set ](#set)
- [1.4.3. Dict](#dict)
+ [1.4.1. List ](#list)\ + [1.4.2. Set ](#set) \ + [1.4.3. Dict](#dict) \ #### [1.4.5. Results](#result) 2. ### [Composite Types](#composite-types) - #### [2.1. Tuples](#tuples)
- #### [2.2. Record Types ](#records)
- #### [2.3. Custom Types](#custom-types)
- [2.3.1. General Case ](#general-case)
- [2.3.2. Special Cases](#special-cases)
- [- No-arg Constructor](#)
- [- Single Constructor](#)
+ #### [2.1. Tuples](#tuples) \ + #### [2.2. Record Types ](#records) \ + #### [2.3. Custom Types](#custom-types) \ + [2.3.1. General Case ](#general-case) \ + [2.3.2. Special Cases](#special-cases) \ + [- No-arg Constructor](#) \ + [- Single Constructor](#) \ @@ -186,12 +188,12 @@ The format attribute in the JSON schema is used to provide the format for the ti Month types in Morphir are mapped OneOf schema type with a enum list of all the month names #### 1.3. Optional values (Maybe) -

A Maybe type in Morphir refers to a value that may not exist. This means that it could either be a value or a null. There are two approaches to handling Maybes.
-1. Set the value of the type to an array of two strings: the type, and "null"
+

A Maybe type in Morphir refers to a value that may not exist. This means that it could either be a value or a null. There are two approaches to handling Maybes.\ +1. Set the value of the type to an array of two strings: the type, and "null" \ 2. Treat a Maybe as a [custom type](#custom-types) with two constructors: the type and null Here, we adopt the second approach. Therefore, the model -
+\ ```elm type alias Manager = @@ -461,7 +463,7 @@ The resulting "anyOf" schema would be as shown below: } ``` #### 2.3.2. Special Cases - **- No-arg Constructor
** + **No-arg Constructor** \ As mentioned previously, when a constructor in a union type has zero arguments, then it maps to a ```const``` schema The model: ```elm @@ -475,7 +477,7 @@ would generate the schema: } ``` - **- Single Constructor
** + **- Single Constructor \ ** When a constructor doesn't have any arguments it behaves like an enum value. The format described above would dictate that we map those to single element arrays in JSON but for simplicity we will map them to just a string value: diff --git a/docs/morphir_community.md b/docs/morphir-community.md similarity index 100% rename from docs/morphir_community.md rename to docs/morphir-community.md diff --git a/docs/morphirDocumentation.html b/docs/morphir-documentation.html similarity index 100% rename from docs/morphirDocumentation.html rename to docs/morphir-documentation.html diff --git a/docs/regtech_modeling.md b/docs/regtech-modeling.md similarity index 100% rename from docs/regtech_modeling.md rename to docs/regtech-modeling.md diff --git a/docs/Scala-Json-Backend.md b/docs/scala-json-backend.md similarity index 100% rename from docs/Scala-Json-Backend.md rename to docs/scala-json-backend.md diff --git a/docs/TestingFramework-README.md b/docs/testing-framework-readme.md similarity index 100% rename from docs/TestingFramework-README.md rename to docs/testing-framework-readme.md diff --git a/docs/user-guide-readme.md b/docs/user-guide-readme.md index 090f2aee9..afd3a26f5 100644 --- a/docs/user-guide-readme.md +++ b/docs/user-guide-readme.md @@ -11,11 +11,11 @@ This guide is for business users, analysts, and developers who want to use Morph 1. [Getting Setup](#) 1. [Installation](installation.md) - 1. [Editor Setup](editor_setup.md) - 1. [The Morphir Tools](command_line_tools.md) - 1. [Compile](command_line_tools.md#Compile) - 1. [Visualize](command_line_tools.md#Visualize) - 1. [Generate](command_line_tools.md#Generate) + 1. [Editor Setup](editor-setup.md) + 1. [The Morphir Tools](command-line-tools.md) + 1. [Compile](command-line-tools.md#Compile) + 1. [Visualize](command-line-tools.md#Visualize) + 1. [Generate](command-line-tools.md#Generate)

diff --git a/docs/whats_it_about.md b/docs/whats-it-about.md similarity index 100% rename from docs/whats_it_about.md rename to docs/whats-it-about.md diff --git a/docs/why_functional_programming.md b/docs/why-functional-programming.md similarity index 100% rename from docs/why_functional_programming.md rename to docs/why-functional-programming.md diff --git a/docs/Working-With-Results-in-Elm.md b/docs/working-with-results-in-elm.md similarity index 86% rename from docs/Working-With-Results-in-Elm.md rename to docs/working-with-results-in-elm.md index 894eb47cf..3265841e2 100644 --- a/docs/Working-With-Results-in-Elm.md +++ b/docs/working-with-results-in-elm.md @@ -2,14 +2,14 @@ This post explains the Result type in the Elm Programming Language and use cases in Morphir. ##Content -1. [Overview of the Result Type](#)
+1. [Overview of the Result Type](#) 2. [Mapping Results (map)](#) -3. [Chaining Results (andThen)](#)
-4. [Result Error Handling](#)
-5. [Use Cases in Morphir](#)

+3. [Chaining Results (andThen)](#) +4. [Result Error Handling](#) +5. [Use Cases in Morphir](#) -###1. [Overview of the Result Type](#)
+###1. [Overview of the Result Type](#) Result is a built-in type in Elm that accepts two arguments: error and value. It represents the result of a computation that has the possibility of failure. The two types of constructors for the result type are given below: ``` @@ -17,22 +17,22 @@ type Result error value = Ok value | Err error ``` -
-A result could be either:
- - OK - which means the operation succeeded
- - Err - which means that the operation failed

+ +A result could be either: + - OK - which means the operation succeeded + - Err - which means that the operation failed \ So the Result type has two parameters: error and value. It also has two constructors: Ok and Err. -
-###2. [Mapping Results (map)](#)
+ +###2. [Mapping Results (map)](#) When a computation returns a Result, it is common to use the map function to further process the Result. If the result is Ok (which means that it is successful), then the function is applied and a value is returned. If however, the result fails, then the error is propagated. An example is given below taken from the [String.elm](#) file **Example 1** -This example is taken from the String module
+This example is taken from the String module ``` evaluate "" value |> Result.map @@ -40,7 +40,7 @@ evaluate "" value ``` In the snippet, the evaluate function is called which takes two string argumnents (an empty string and a value) and returns a **Result Error String**. The output of the evaluate -function is transformed to a **Value Literal** using the map function.
+function is transformed to a **Value Literal** using the map function. **Example 2** In the example below which is taken from the [List Module](#), we use the map function to @@ -54,7 +54,7 @@ listItems ``` -**Example 3**
+**Example 3** \ This example is taken from the [CLI.elm module](#). ``` @@ -68,12 +68,11 @@ In the snippet, the **Decode.decodeValue** function takes a decoder and a value. The value argument is the distributionJson returned from IR.fromDistribution while the decoder is returned from DistributionCodec.decodeVersionedDistribution function. The Decode.decodeValue returns a Result. A successful result (which is a distribution) is -transformed into an IR using the map functon applied to IR.fromDistribution. -
-
+transformed into an IR using the map function applied to IR.fromDistribution. -### 3. [Chaining Results (andThen)](#)

+ +### 3. [Chaining Results (andThen)](#) Sometimes we could have a sequence of operations where each of them have the possibility of failure. The signature for the **andThen** function is given below: @@ -84,44 +83,44 @@ andThen callback result = Ok value -> callback value Err msg -> Err msg ``` -In the code snippet above, the andThen function takes two arguments:
+In the code snippet above, the andThen function takes two arguments: * **the callback** - this is the function that gets called on the value when the result is OK * **result** = this is Result type returned by a prior computation -

-###4. [Result Error Handling](#)
+ +###4. [Result Error Handling](#) In the previous examples, we covered how to handle successful results. Let's now examine how to handle errors. Elm provides the following function that could be used for handling errors with the result type -
+ ``` withDefault: a -> Result x a -> a ``` -This function returns a specified default value when the result is Err
+This function returns a specified default value when the result is Err ``` toMaybe: Result x a -> Maybe a ``` -This function returns a specified default value when the result is Err
+This function returns a specified default value when the result is Err ``` fromMaybe: x -> Maybe a -> Result x a ``` -This function converts a Maybe to a Result
+This function converts a Maybe to a Result ``` mapError: (x -> y) -> Result x a -> Result y a ``` Just like the map function mentioned earlier, the mapError function allows you to apply a function -to a result if it is an error
-
+to a result if it is an error + -###5. [Use Cases in Morphir](#)
+###5. [Use Cases in Morphir](#) To understand the result type more clearly, we would look at a number of use cases from the Morphir codebase. -**Returning a Result Type**
+**Returning a Result Type** \ In a computatation that contains the possibility of failure, it would be necessary to return a Result type. For example, the code snippet below taken from the JSONBackend.elm file contains a function that returns the encoder reference for a given type: @@ -143,7 +142,7 @@ For **Type.Variable**, the operation produces a **Scala.Variable** type which is into a Result type using the Ok constructor. This could also achieved by piping the output into Result.Ok. -**Handling Result Using mapError**
+**Handling Result Using mapError** \ The snippet below shows the use of mapError in handling Error from the Result type. It is taken from [Incremental Frontend](#) module @@ -160,11 +159,11 @@ In the example, the parseSource function returns a **Result** type but the **Elm function returns a **Result (List Deadend) RawFile**. This means that we need to transform both the two parameters of the Result. The **mapError** transforms the **(List Deadend)** into **Error** while the *map* transforms -the *RawFile* into *ParsedModule*
+the *RawFile* into *ParsedModule* **Chaining Result Example** The example below shows the use of Result chaining taken from [Spark Backend](#) module. -
+ ``` mapFunctionBody : TypedValue -> Result Error Scala.Value mapFunctionBody body = From b73b4fb84c358b105a6a7a7a51030fc3e5044ab2 Mon Sep 17 00:00:00 2001 From: Kindson The Genius <35315234+KindsonTheGenius@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:45:02 +0000 Subject: [PATCH 4/5] Fixed all tagging issues --- docs/cadl-doc.md | 4 +- docs/cli-cli2-merging-docs.md | 92 +++++++++++++++---------------- docs/json-schema-mappings.md | 14 +++-- docs/morpir-developers-guide.md | 74 ++++++++++++------------- docs/scala-backend.md | 40 +++++++------- docs/scala-json-codecs-backend.md | 16 +++--- docs/spark-backend.md | 46 ++++++++-------- docs/spark-testing-framework.md | 2 +- docs/user-guide-index.md | 2 +- 9 files changed, 147 insertions(+), 143 deletions(-) diff --git a/docs/cadl-doc.md b/docs/cadl-doc.md index efed7202c..52aee6a5d 100644 --- a/docs/cadl-doc.md +++ b/docs/cadl-doc.md @@ -1,8 +1,10 @@ +## Morphir-Cadl Mapping # [Morphir](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) to [Cadl Type](https://microsoft.github.io/cadl/docs/language-basics/type-relations/) Mappings -## Overview This is a documentation of the mapping strategy from Morphir types to Cadl types. This document describes how types in Morphir Models are represented in Cadl. Below is a quick overview of the mapping in the table: + + | | Type | Cadl Type | Comment | |-------------------------------------------------------|-------------------------------------|------------------------------------------|-----------------------------------------------------| | [Basic Types](#basic-types) | | | | diff --git a/docs/cli-cli2-merging-docs.md b/docs/cli-cli2-merging-docs.md index eb1711d89..82c7b9ca0 100644 --- a/docs/cli-cli2-merging-docs.md +++ b/docs/cli-cli2-merging-docs.md @@ -3,49 +3,49 @@ This document contains cli commands that were migrated from the old cli, which is `morphir-elm`, into the new all cli commands supported by the old cli, and the **current** cli, `morphir`. -| Command | Flags | Description | Old CLI | New CLI | New Command | Comment | -|-------------------|-------------------------------------------------------|--------------------------------------------------------------------------------|:--------:|:--------:|:------------------------:|----------------------------------------------------| -| `make` | | | ✅ | ✅ | `morphir make` | | -| | -p , --project-dir \ | Root directory of the project where morphir.json is located. | | | | | -| | -o , --output \ | Target file location where the Morphir IR will be saved. | | | | | -| | -t, --types-only | Only include type information in the IR, no values. | | | | | -| | -f, --fallback-cli | Use old cli make function. | | | | | -| `test` | | | ✅ | ✘ | `morphir test` | | -| | -p, --project-dir \ | Root directory of the project where morphir.json is located. | | | | | -| `stats` | | | ✘ | ✅ | `morphir stats` | | -| | -i, --input \ | Source location where the Morphir IR will be loaded from. | | | | | -| | -o, --output \ | Target location where the generated code will be saved. | | | | | -| `dockerize` | | | ✘ | ✅ | `morphir dockerize` | | -| | -p, --project-dir \ | Root directory of the project where morphir.json is located | | | | | -| | -f, --force | Overwrite any Dockerfile in target location | | | | -| `gen` | | | ✅ | ✘ | | | -| | -i, --input | Source location where the Morphir IR will be loaded from. | | | | | -| | -o, --output | Target location where the generated code will be saved. | | | | | -| | -t, --target | Language to Generate (Scala | Cadl | JsonSchema | TypeScript). | | | | To generate Scala, use command `morphir scala-gen` | -| | -e, --target-version | Language version to Generate. | | | | | -| | -c, --copy-deps | Copy the dependencies used by the generated code to the output path | | | | | -| | -m, --modules-to-include | Limit the set of modules that will be included | | | | | -| | -s, --include-codecs | Generate JSON codecs | | | | | -| | -f, --filename | Filename of the generated JSON Schema | | | | | -| | -cc, --custom-config | A filepath to load additional configuration for the backend | | | | | -| `scala-gen` | | | ✘ | ✅ | `morphir scala gen` | | -| | -i, --input \ | Source location where the Morphir IR will be loaded from | | | | | -| | -o, --output \ | Target location where the generated code will be saved | | | | | -| | -t, --target \ | Language to Generate | | | | Deprecated | -| | -e, --target-version \ | Language version to Generate | | | | | -| | -c, --copy-deps | Copy the dependencies used by the generated code to the output path | | | | | -| | -s, --include-codecs | Generate the scala codecs as well | | | | | -| | -m, --limitToModules | Limit the set of modules that will be included | | | | | -| `json-schema-gen` | | | ✘ | ✅ | `morphir jsonschema gen` | | -| | -i, --input \ | Source location where the Morphir IR will be loaded from | | | | | -| | -o, --output \ | Target location where the generated code will be saved | | | | | -| | -t, --target \ | Language to Generate | | | | Deprecated | -| | -e, --target\-version \ | Language version to Generate | | | | | -| | -f, --filename | Filename of the generated JSON Schema | | | | | -| | -m, --limit-to-modules | Limit the set of modules that will be included | | | | | -| | -g, --group-schema-by | Group generate schema by package, module or type | | | | | -| | -c, --use-config | Use configuration specified in the config file | | | | | -| | -ls, --include \' | Limit what will be included | | | | | -| `develop` | | | ✅ | ✘ | `morphir develop` | | | -| | -p, --port \ | Port to bind the web server to | | | | | -| | -o, --host \ | Host to bind the web server to. | | | | | +| Command | Flags | Description | Old CLI | New CLI | New Command | Comment | +|-------------------|------------------------------------------------------|--------------------------------------------------------------------------------|:--------:|:--------:|:------------------------:|----------------------------------------------------| +| `make` | | | ✅ | ✅ | `morphir make` | | +| | -p , --project-dir `` | Root directory of the project where morphir.json is located. | | | | | +| | -o , --output `` | Target file location where the Morphir IR will be saved. | | | | | +| | -t, --types-only | Only include type information in the IR, no values. | | | | | +| | -f, --fallback-cli | Use old cli make function. | | | | | +| `test` | | | ✅ | ✘ | `morphir test` | | +| | -p, --project-dir `` | Root directory of the project where morphir.json is located. | | | | | +| `stats` | | | ✘ | ✅ | `morphir stats` | | +| | -i, --input `` | Source location where the Morphir IR will be loaded from. | | | | | +| | -o, --output `` | Target location where the generated code will be saved. | | | | | +| `dockerize` | | | ✘ | ✅ | `morphir dockerize` | | +| | -p, --project-dir `` | Root directory of the project where morphir.json is located | | | | | +| | -f, --force | Overwrite any Dockerfile in target location | | | | +| `gen` | | | ✅ | ✘ | | | +| | -i, --input `` | Source location where the Morphir IR will be loaded from. | | | | | +| | -o, --output `` | Target location where the generated code will be saved. | | | | | +| | -t, --target `` | Language to Generate (Scala | Cadl | JsonSchema | TypeScript). | | | | To generate Scala, use command `morphir scala-gen` | +| | -e, --target-version `` | Language version to Generate. | | | | | +| | -c, --copy-deps | Copy the dependencies used by the generated code to the output path | | | | | +| | -m, --modules-to-include `` | Limit the set of modules that will be included | | | | | +| | -s, --include-codecs | Generate JSON codecs | | | | | +| | -f, --filename `` | Filename of the generated JSON Schema | | | | | +| | -cc, --custom-config `` | A filepath to load additional configuration for the backend | | | | | +| `scala-gen` | | | ✘ | ✅ | `morphir scala gen` | | +| | -i, --input `` | Source location where the Morphir IR will be loaded from | | | | | +| | -o, --output `` | Target location where the generated code will be saved | | | | | +| | -t, --target `` | Language to Generate | | | | Deprecated | +| | -e, --target-version `` | Language version to Generate | | | | | +| | -c, --copy-deps | Copy the dependencies used by the generated code to the output path | | | | | +| | -s, --include-codecs `` | Generate the scala codecs as well | | | | | +| | -m, --limitToModules `` | Limit the set of modules that will be included | | | | | +| `json-schema-gen` | | | ✘ | ✅ | `morphir jsonschema gen` | | +| | -i, --input `` | Source location where the Morphir IR will be loaded from | | | | | +| | -o, --output `` | Target location where the generated code will be saved | | | | | +| | -t, --target `` | Language to Generate | | | | Deprecated | +| | -e, --target\-version `` | Language version to Generate | | | | | +| | -f, --filename `` | Filename of the generated JSON Schema | | | | | +| | -m, --limit-to-modules `` | Limit the set of modules that will be included | | | | | +| | -g, --group-schema-by `` | Group generate schema by package, module or type | | | | | +| | -c, --use-config | Use configuration specified in the config file | | | | | +| | -ls, --include `` | Limit what will be included | | | | | +| `develop` | | | ✅ | ✘ | `morphir develop` | | | +| | -p, --port `` | Port to bind the web server to | | | | | +| | -o, --host `` | Host to bind the web server to. | | | | | diff --git a/docs/json-schema-mappings.md b/docs/json-schema-mappings.md index bc08f485d..be22f7bdb 100644 --- a/docs/json-schema-mappings.md +++ b/docs/json-schema-mappings.md @@ -2,7 +2,7 @@ This is a documentation of the mapping strategy from Morphir types to Json Schema. This document describes how Morphir Models maps to Json Schema. Json Schema Reference can be found [here](http://json-schema.org/understanding-json-schema/reference/index.html) -
+\ Additional reading: * [Sample Json Schema](json-schema-sample.json) * [Testing Strategy](json-schema-backend-testplan.md) @@ -36,16 +36,16 @@ Run the ```elm morphir-elm gen -t JsonSchema``` to generate the Json Schema **Note** - The generated schema is named `.json` by default. But you can specify the filename optionally for the schema using the -f flag. -


-

+ +\ Next, we will get into some specific cases that may need further explanation. The rest of the explains how each Morphir type maps to the Json Schema Types. 1. ### [ SDK Types](#sdk-types) #### [1.1. Basic types](#basic-types) - [1.1.1. Bool ](#bool)
+ [1.1.1. Bool ](#bool)\ [1.1.2. Int ](#int)\ [1.1.3. Float ](#float)\ [1.1.4. Char ](#char)\ @@ -188,7 +188,7 @@ The format attribute in the JSON schema is used to provide the format for the ti Month types in Morphir are mapped OneOf schema type with a enum list of all the month names #### 1.3. Optional values (Maybe) -

A Maybe type in Morphir refers to a value that may not exist. This means that it could either be a value or a null. There are two approaches to handling Maybes.\ +A Maybe type in Morphir refers to a value that may not exist. This means that it could either be a value or a null. There are two approaches to handling Maybes.\ 1. Set the value of the type to an array of two strings: the type, and "null" \ 2. Treat a Maybe as a [custom type](#custom-types) with two constructors: the type and null Here, we adopt the second approach. @@ -519,6 +519,7 @@ type alias Address = } ``` Json Schema: + ```json "Records.Bank": { "type": "object", @@ -534,4 +535,5 @@ Json Schema: ``` ## anyOf -The anyOf keyword is used to relate a schema with it's subschemas. +The anyOf keyword is used to relate a schema +with it's subschemas. diff --git a/docs/morpir-developers-guide.md b/docs/morpir-developers-guide.md index 61ded36fb..a78b707d4 100644 --- a/docs/morpir-developers-guide.md +++ b/docs/morpir-developers-guide.md @@ -8,45 +8,45 @@ Finally, it provides a step by step walk-throughs on how various Morphir compone 2. Existing team members intending to improve their abilities on Language Design concepts ##Content -1. [Getting Started with Morphir](https://github.com/finos/morphir-elm/blob/main/README.md)
+1. [Getting Started with Morphir](https://github.com/finos/morphir-elm/blob/main/README.md) \ 2. [Overview of Morphir](#) -3. [The Morphir Architecture](#)
-4. [The Morphir SDK](#)
-5. [Morphir Commands Processing](Morphir-elm Commands Processing)
- 1. [morphir-elm make](#)
- 2. [morphir-elm gen](#)
- 3. [morphir-elm test](#)
- 4. [morphir-elm develop](#)
-6. [Interoperability With JavaScript](#)
-7. [Testing Framework](#)
-8. [The Morphir IR](#)
- 1. [Overview of the Morphir IR](#)
- 2. [Distribution](#)
- 3. [Package](#)
- 4. [Module](#)
- 5. [Types](#)
- 6. [Values](#)
- 7. [Names](#)
-9. [The Morphir Frontends](#)
- 1. [Elm Frontend](#)
- 2. [Elm Incremental Frontend](#)
-10. [The Morphir Backends](#)
+3. [The Morphir Architecture](#) \ +4. [The Morphir SDK](#) \ +5. [Morphir Commands Processing](Morphir-elm Commands Processing) \ + 1. [morphir-elm make](#) \ + 2. [morphir-elm gen](#) \ + 3. [morphir-elm test](#) \ + 4. [morphir-elm develop](#) \ +6. [Interoperability With JavaScript](#) \ +7. [Testing Framework](#) \ +8. [The Morphir IR](#) \ + 1. [Overview of the Morphir IR](#) \ + 2. [Distribution](#) \ + 3. [Package](#) \ + 4. [Module](#) \ + 5. [Types](#) \ + 6. [Values](#) \ + 7. [Names](#) \ +9. [The Morphir Frontends](#) \ + 1. [Elm Frontend](#) \ + 2. [Elm Incremental Frontend](#) \ +10. [The Morphir Backends](#) \ 1. [Scala Backend](#) -11. [Working with CODECS](#)
- 1. [Introduction to Encoding/Decoding](#)
- 2. [JSON Decoder Building Blocks](#)
- 3. [Combining Decoders](#)
- 4. [JSON Decode Pipeline](#)
- 5. [Writing Encoders and Decoders in Elm](#)
- 6. [Standard Codecs in Morphir](#)
-12. [NPM and Elm Packages](#)
-13. [Introduction to Combinator Parsing in Scala](#)
- 1. [Overview of Combinator Parsing](#)
- 2. [Parser or Basic Arithmetic Expression](#)
- 3. [Implementing Parsers in Scala](#)
- 4. [Regular Expressions Parser](#)
- 5. [JSON Parser](#)
- 6. [Low-Level Pull Parser API](#)
+11. [Working with CODECS](#) \ + 1. [Introduction to Encoding/Decoding](#) \ + 2. [JSON Decoder Building Blocks](#) \ + 3. [Combining Decoders](#) \ + 4. [JSON Decode Pipeline](#) \ + 5. [Writing Encoders and Decoders in Elm](#) \ + 6. [Standard Codecs in Morphir](#) \ +12. [NPM and Elm Packages](#) \ +13. [Introduction to Combinator Parsing in Scala](#) \ + 1. [Overview of Combinator Parsing](#) \ + 2. [Parser or Basic Arithmetic Expression](#) \ + 3. [Implementing Parsers in Scala](#) \ + 4. [Regular Expressions Parser](#) \ + 5. [JSON Parser](#) \ + 6. [Low-Level Pull Parser API](#) \ diff --git a/docs/scala-backend.md b/docs/scala-backend.md index 13f58cdbe..1dc82dba8 100644 --- a/docs/scala-backend.md +++ b/docs/scala-backend.md @@ -3,9 +3,9 @@ The Scala backend takes the Morphir IR as the input and returns an in-memory representation of files generated - FileMap The consumer is responsible for getting the input IR and saving the output to the file-system. -The transformation from the Morphir IR to the FileMap is based on the Scala AST.

-[1. Reading the Input IR](#)
-[2. Scala Code Generation](#)
+The transformation from the Morphir IR to the FileMap is based on the Scala AST.\\ +[1. Reading the Input IR](#) \ +[2. Scala Code Generation](#)\ [3. Writing Output to File System](#) ## **1. Reading Input IR** @@ -37,7 +37,7 @@ fileMap = The code generation phase consists of functions that transform the distribution into a FileMap -
+\ ## **2. Code Generation** The code generation consists of a number of mapping functions that map the Morphir IR types to Scala Types. @@ -47,15 +47,15 @@ This is the entry point for the Scala backend. This function take Morphir IR (as a Distribution type) and generates the FileMap of Scala Source codes. A FileMap is a Morphir type and is a dictionary of File path and file content. -
+\ #### mapPackageDefinition This function takes the Distribution, Package path and Package definition and returns a FileMap. This function maps through the modules in the package definition and for each module, it generate a compilation unit for each module by calling the PrettyPrinter.mapCompilationUnit -which returns a compilation unit.
+which returns a compilation unit. \ A compilation unit is a record type with the following fields -

+\\ ``` type alias CompilationUnit = @@ -67,13 +67,13 @@ type alias CompilationUnit = } ``` -
+\ #### mapFQNameToPathAndName Takes a Morphir IR fully-qualified name and maps it to tuple of Scala path and name. A fully qualified name consists of packagPath, modulePath and localName. -
+\ #### mapFQNameToTypeRef Maps a Morphir IR fully-qualified name to Scala type reference. It extracts the path and name @@ -89,45 +89,45 @@ mapFQNameToTypeRef fQName = Scala.TypeRef path (name |> Name.toTitleCase) ``` -
+\ #### mapTypeMember This function maps a type declaration in Morphir to a Scala member declaration. -
+\ #### mapModuleDefinition This function maps a module definition to a list of Scala compilation units. -
+\ #### mapCustomTypeDefinition Maps a custom type to a List of Scala member declaration -
+\ #### mapType Maps a Morphir IR Type to a Scala type -
+\ #### mapFunctionBody Maps an IR value defintion to a Scala value. -
+\ #### mapValue Maps and IR Value type to a Scala value. -
+\ #### mapPattern Maps an IR Pattern type to a Scala Pattern type -
+\ #### mapValueName @@ -136,19 +136,19 @@ Maps an IR value name (List String) to a Scala value (String) #### scalaKeywords A set of Scala keywords that cannot be used as a variable name. -
+\ #### javaObjectMethods We cannot use any method names in `java.lang.Object` because values are represented as functions/values in a Scala object which implicitly inherits those methods which can result in name collisions. -
+\ #### uniqueVarName -
+\ ## **3. Saving Generated Files** diff --git a/docs/scala-json-codecs-backend.md b/docs/scala-json-codecs-backend.md index d1a0705f7..d113b9929 100644 --- a/docs/scala-json-codecs-backend.md +++ b/docs/scala-json-codecs-backend.md @@ -1,7 +1,7 @@ # Scala JSON-Codecs Backend Documentation This document provides a description of the JSON codecs backend. -The Json Codecs Backend for Scala contains functions to generate Codecs from types in the IR.
+The Json Codecs Backend for Scala contains functions to generate Codecs from types in the IR.\ [Circe](https://circe.github.io/circe/) is used as the base JSON library. ```mermaid @@ -9,7 +9,7 @@ graph TD; Backend-->Core; Backend-->Features ``` -The Scala backend is split into two aspects:
+The Scala backend is split into two aspects: \ 1. **Core** - the core Scala codes representing the user business logic 2. **Feature** - the Codecs for each type defined in the input model @@ -66,16 +66,16 @@ Generates and decoder reference for the input type using the FQName #### mapTypeDefinitionToEncoder -Type definition could be any of the following:
-_**Type Alias Definition**_ - maps to an encoder for record type
+Type definition could be any of the following:\ +_**Type Alias Definition**_ - maps to an encoder for record type \ **_Custom Type Definition_** - uses helper functions to build encoder for custom -types

+types \\ #### mapTypeDefinitionToDecoder -Type definition could be any of the following:
-_**Type Alias Definition**_ - maps to an encoder for record type
+Type definition could be any of the following:\ +_**Type Alias Definition**_ - maps to an encoder for record type \ **_Custom Type Definition_** - uses helper functions to build encoder for custom -types

+types \\ #### mapCustomTypeDefinitionToEncoder diff --git a/docs/spark-backend.md b/docs/spark-backend.md index 72c565079..9bdec665c 100644 --- a/docs/spark-backend.md +++ b/docs/spark-backend.md @@ -8,10 +8,10 @@ The Spark API defines types for working with Spark. ## Values The current Spark API defines the following values: -**_spark_**
+**_spark_** \ This is a variable maps to a Scala value -**_dataFrame_**
+**_dataFrame_** \ A DataFrame maps to a Scala type and references org.apache.spark.sql.DataFrame. A dataframe is an untyped view of a spark datase. A dataframe is a dataset of Rows @@ -22,9 +22,9 @@ dataFrame = Scala.TypeRef [ "org", "apache", "spark", "sql" ] "DataFrame" ``` -
+\ -**_literal_**
+**_literal_** \ A literal returns a Scala.Value by applying a Scala.Ref type to a list of arguments. ``` dataFrame : Scala.Type @@ -33,7 +33,7 @@ dataFrame = ``` -_**column**_
+_**column**_ \ This is a reference to a column in a Dataframe. This returns a Scala value by applying a reference to column to a string literal representing the name of the column ``` @@ -43,16 +43,16 @@ dataFrame = ``` -_**when**_
+_**when**_ \ This method takes condition and a then branch and returns a Scala value -**_andWhen_**
+**_andWhen_** \ This method takes three parameters: a condition, a then branch and soFar and return a new value -**_otherwise_**
+**_otherwise_** \ This method takes an elseBranch and a soFar and returns new Scala Value ``` dataFrame : Scala.Type @@ -61,7 +61,7 @@ dataFrame = ``` -_**alias**_
+_**alias**_ \ An alias is used to reference column name, typed column and data set. ``` dataFrame : Scala.Type @@ -70,7 +70,7 @@ dataFrame = ``` -**_select_**
+**_select_** \ Select is used to represent a projection in a relation. It takes a list of columns and returns a Scala Value representing a dataset @@ -87,7 +87,7 @@ select columns from = ) ``` -**_filter_**
+**_filter_** \ This method is used to return a subset of the data items from a dataset ``` @@ -103,7 +103,7 @@ filter predicate from = ``` -_**join**_
+_**join**_ \ This function is used to represent a join operation between two or more relations. ``` filter : Scala.Value -> Scala.Value -> Scala.Value @@ -117,7 +117,7 @@ filter predicate from = ] ``` -_**case statements**_
+_**case statements**_ \ Simple case statements of: * a series of literals * ends with a default case @@ -144,7 +144,7 @@ org.apache.spark.sql.functions.when( ).otherwise(false) ``` -_**List.member constructs**_
+_**List.member constructs**_ \ When List.member is used in conjunction with a List.filter function, such as in the following examples: ``` testEnumListMember : List { product : Product } -> List { product : Product } @@ -317,7 +317,7 @@ antiques.select( ## Types The current Spark API processes the following types: -_**Bool**_
+_**Bool**_ \ Values translated form basic Elm Booleans are treated as basic Scala Booleans, i.e. ``` testBool : List { foo : Bool } -> List { foo : Bool } @@ -336,7 +336,7 @@ gets translated into source.filter((org.apache.spark.sql.functions.col("foo")) === (false)) ``` -_**Float**_
+_**Float**_ \ Values translated from basic Elm Floating-point numbers are treated as basic Scala Doubles. They use `org.apache.spark.sql.types.DoubleType` and their literals do not have a trailing 'f', i.e. `1.23` not `1.23f`. i.e. @@ -357,7 +357,7 @@ gets translated into source.filter((org.apache.spark.sql.functions.col("foo")) === (9.99)) ``` -_**Int**_
+_**Int**_ \ Values translated from basic Elm Integers are treated as basic Scala Integers, i.e. ``` testInt : List { foo : Int } -> List { foo : Int } @@ -376,7 +376,7 @@ gets translated into source.filter((org.apache.spark.sql.functions.col("foo")) === (13)) ``` -_**String**_
+_**String**_ \ Values translated from basic Elm Strings are treated as basic Scala Strings, i.e. ``` testString : List { foo : String } -> List { foo : String } @@ -395,7 +395,7 @@ gets translated into source.filter((org.apache.spark.sql.functions.col("foo")) === ("bar")) ``` -_**Enum**_
+_**Enum**_ \ Elm Union types with no arguments (or Constructors in Morphir IR), are translated into String Literals. For instance: ``` @@ -418,12 +418,12 @@ gets translated into Currently the implementation doesn't check that the Constructor has no arguments. Nor does the current implementation check whether a Constructor has Public access, and only consider those to be Enums. -_**Maybe**_
+_**Maybe**_ \ Maybes are how Elm makes it possible to return a value or Nothing, equivalent to null in other languages. In Spark, all pure Spark functions and operators handle null gracefully (usually returning null itself if any operand is null). -**Just**
+**Just** \ In Elm, comparison against Maybes must be explicitly against `Just `. In Spark, no special treatment is needed to compare against a value that may be null. Therefore, elm code that looks like: @@ -444,7 +444,7 @@ gets translated in Spark to source.filter((org.apache.spark.sql.functions.col("foo")) === (true)) ``` -**Nothing**
+**Nothing** \ Where Elm code compares against Nothing, Morphir will translate this into a comparison to null in Spark. For example, to take a list of records and filter out null records in Elm, we would do: @@ -466,7 +466,7 @@ def testMaybeBoolConditional( source.filter(org.apache.spark.sql.functions.isnull(org.apache.spark.sql.functions.col("foo"))) ``` -**Maybe.map**
+**Maybe.map** \ Elm has `Maybe.map` and `Maybe.defaultValue` to take a Maybe and execute one branch of code if the Maybe isn't Nothing, and another branch if it is. diff --git a/docs/spark-testing-framework.md b/docs/spark-testing-framework.md index e9b2df949..60e4cb6bd 100644 --- a/docs/spark-testing-framework.md +++ b/docs/spark-testing-framework.md @@ -46,7 +46,7 @@ testExampleMax source = ``` #### 2) Write code to generate input test data -- If a new type has been designed for the test then new data of that type needs to be generated to use as an input for the test. This can be done in `/morphir-elm/tests-integration/spark/elm-tests/tests` using some elm code placed in a Generate....elm file. This can be done using the 'flatten' and 'generator' functions defined in GenerateAntiqueTestData.elm. It is simple to create code to generate input data by following the example set by the other Generate....elm files in the same directory. All Generate*.elm files should be placed in the `/morphir-elm/tests-integration/spark/elm-tests/tests` directory. The Generate*.elm file and its counterpart *DataSource.elm must be of the form " GenerateData.elm" and "DataSource.elm". +- If a new type has been designed for the test then new data of that type needs to be generated to use as an input for the test. This can be done in `/morphir-elm/tests-integration/spark/elm-tests/tests` using some elm code placed in a Generate....elm file. This can be done using the 'flatten' and 'generator' functions defined in GenerateAntiqueTestData.elm. It is simple to create code to generate input data by following the example set by the other Generate....elm files in the same directory. All Generate*.elm files should be placed in the `/morphir-elm/tests-integration/spark/elm-tests/tests` directory. The Generate*.elm file and its counterpart *DataSource.elm must be of the form " Generate `` Data.elm" and " `` DataSource.elm". Some example data generation code in elm can be seen below. ``` diff --git a/docs/user-guide-index.md b/docs/user-guide-index.md index 2866c4687..83cbe0828 100644 --- a/docs/user-guide-index.md +++ b/docs/user-guide-index.md @@ -8,7 +8,7 @@ The purpose of the document is to provide a detailed explanation of how to use t 1. [Background](#) 2. [What is all About](#) 3. [The Morphir Community](#) -4. [Getting Started with Morphir](https://github.com/finos/morphir-elm/blob/main/README.md)
+4. [Getting Started with Morphir](https://github.com/finos/morphir-elm/blob/main/README.md) \ 5. [Quick Install](#) 6. [How to Write Business Logic](#) 1. [What Makes a Good Model](#) From 117ca3e1ac68764bee9200ce64336011c9bb589e Mon Sep 17 00:00:00 2001 From: Kindson The Genius <35315234+KindsonTheGenius@users.noreply.github.com> Date: Thu, 20 Apr 2023 08:27:27 +0000 Subject: [PATCH 5/5] Standardized the document titles --- ...park-backend-as-a-special-case-of-a-relational-backend.md | 2 +- docs/cadl-doc.md | 4 ++-- docs/codec-docs.md | 2 +- docs/error-append-not-supported.md | 1 + docs/insight-readme.md | 2 +- docs/json-codecs-doc.md | 2 +- docs/json-schema-backend-testplan.md | 2 +- docs/json-schema-mappings.md | 2 +- docs/{json-schema-sample.json => json-schema-sample.md} | 5 ++++- docs/relational-backend.md | 2 +- docs/scala-json-backend.md | 2 +- docs/spark-backend-joins.md | 2 +- docs/spark-backend.md | 2 +- docs/spark-testing-framework.md | 1 + docs/spring-boot-readme.md | 2 +- docs/table-template.md | 1 + docs/testing-framework-readme.md | 2 +- 17 files changed, 21 insertions(+), 15 deletions(-) rename docs/{json-schema-sample.json => json-schema-sample.md} (97%) diff --git a/docs/0001-implement-the-spark-backend-as-a-special-case-of-a-relational-backend.md b/docs/0001-implement-the-spark-backend-as-a-special-case-of-a-relational-backend.md index 097ed19ed..27de415f7 100644 --- a/docs/0001-implement-the-spark-backend-as-a-special-case-of-a-relational-backend.md +++ b/docs/0001-implement-the-spark-backend-as-a-special-case-of-a-relational-backend.md @@ -1,4 +1,4 @@ -# Implement the Spark backend as a special case of a Relational backend +# Spark backend as a special case of a Relational backend ## Context and Problem Statement diff --git a/docs/cadl-doc.md b/docs/cadl-doc.md index 52aee6a5d..203876b46 100644 --- a/docs/cadl-doc.md +++ b/docs/cadl-doc.md @@ -1,5 +1,5 @@ -## Morphir-Cadl Mapping -# [Morphir](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) to [Cadl Type](https://microsoft.github.io/cadl/docs/language-basics/type-relations/) Mappings +# Morphir-Cadl Mapping +## [Morphir](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) to [Cadl Type](https://microsoft.github.io/cadl/docs/language-basics/type-relations/) Mappings This is a documentation of the mapping strategy from Morphir types to Cadl types. This document describes how types in Morphir Models are represented in Cadl. Below is a quick overview of the mapping in the table: diff --git a/docs/codec-docs.md b/docs/codec-docs.md index 49e395127..c7e2658af 100644 --- a/docs/codec-docs.md +++ b/docs/codec-docs.md @@ -1,4 +1,4 @@ -## JSON serialization support for generated Scala classes +# JSON serialization support for generated Scala classes The purpose of this documentation is to give an explanation on how the JSON Codec Backend works and how to use it. This backend is a feature built on top of the Scala backend, which allows you to read Scala types that the Scala backend generates from JSON and write to JSON. diff --git a/docs/error-append-not-supported.md b/docs/error-append-not-supported.md index ef0452a4d..75373fb71 100644 --- a/docs/error-append-not-supported.md +++ b/docs/error-append-not-supported.md @@ -1,3 +1,4 @@ +# Error Append not Supported The ++ operator assumes a type inferencer that can tell the difference between String and List. These are the only two types that are part of the `appendable` type-class. Until the type inferencer is available we will error out to remove ambiguity. \ No newline at end of file diff --git a/docs/insight-readme.md b/docs/insight-readme.md index aa8c649ce..70a8a3154 100644 --- a/docs/insight-readme.md +++ b/docs/insight-readme.md @@ -1,4 +1,4 @@ -##Insight API Guide +#Insight API Guide The purpose of this document is how we can use Insight API into any UI. ## Prerequisites diff --git a/docs/json-codecs-doc.md b/docs/json-codecs-doc.md index 3fd166745..4d6076ff6 100644 --- a/docs/json-codecs-doc.md +++ b/docs/json-codecs-doc.md @@ -1,4 +1,4 @@ -## Json Codec Backend +# Json Codec Backend The purpose of this documentation is to give an explanation of how the Json Codec Backend works and how to use it. The Json Codec backend is a tool that generates encoders and decoders from a Morphir IR using the Circe JSON library. Codecs are generated in Scala diff --git a/docs/json-schema-backend-testplan.md b/docs/json-schema-backend-testplan.md index b49810301..07767d29f 100644 --- a/docs/json-schema-backend-testplan.md +++ b/docs/json-schema-backend-testplan.md @@ -1,4 +1,4 @@ -## Json Schema Backend Test Specification +# Json Schema Backend Test Specification This document speficies the testing strategy for the Json Schema backend. 1. [Unit Tests (Elm)](#unitTests) diff --git a/docs/json-schema-mappings.md b/docs/json-schema-mappings.md index be22f7bdb..453ddf981 100644 --- a/docs/json-schema-mappings.md +++ b/docs/json-schema-mappings.md @@ -4,7 +4,7 @@ This document describes how Morphir Models maps to Json Schema. Json Schema Reference can be found [here](http://json-schema.org/understanding-json-schema/reference/index.html) \ Additional reading: -* [Sample Json Schema](json-schema-sample.json) +* [Sample Json Schema](json-schema-sample.md) * [Testing Strategy](json-schema-backend-testplan.md) ## Overview diff --git a/docs/json-schema-sample.json b/docs/json-schema-sample.md similarity index 97% rename from docs/json-schema-sample.json rename to docs/json-schema-sample.md index b30fda63c..9a4e6ff95 100644 --- a/docs/json-schema-sample.json +++ b/docs/json-schema-sample.md @@ -1,3 +1,5 @@ +# Json Schema Sample +```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://example.com/types.schema.json", @@ -77,4 +79,5 @@ ] } } -} \ No newline at end of file +} +``` \ No newline at end of file diff --git a/docs/relational-backend.md b/docs/relational-backend.md index 23e1ed33d..29261e809 100644 --- a/docs/relational-backend.md +++ b/docs/relational-backend.md @@ -1,4 +1,4 @@ -# **Relational Backend Documentation** +# Relational Backend Documentation ## Joins diff --git a/docs/scala-json-backend.md b/docs/scala-json-backend.md index 04e20fe89..882f35fe6 100644 --- a/docs/scala-json-backend.md +++ b/docs/scala-json-backend.md @@ -1,2 +1,2 @@ -# **Scala JSON Backend Documentation** +# Scala JSON Backend Documentation diff --git a/docs/spark-backend-joins.md b/docs/spark-backend-joins.md index c02da1530..1fd53a05d 100644 --- a/docs/spark-backend-joins.md +++ b/docs/spark-backend-joins.md @@ -1,4 +1,4 @@ - +# Spark Backend Joins Let's start by defining an example model that does some joins: ```elm diff --git a/docs/spark-backend.md b/docs/spark-backend.md index 9bdec665c..b71a1c2b5 100644 --- a/docs/spark-backend.md +++ b/docs/spark-backend.md @@ -1,4 +1,4 @@ -# **Spark Backend/API Documentation** +# Spark Backend/API Documentation This is the entry point for the Spark Backend. # The Spark API diff --git a/docs/spark-testing-framework.md b/docs/spark-testing-framework.md index 60e4cb6bd..35729541d 100644 --- a/docs/spark-testing-framework.md +++ b/docs/spark-testing-framework.md @@ -1,3 +1,4 @@ +# Spark Testing Framework ## Spark CSV Testing guide The purpose of this document is to show how someone can use and edit the spark tests. diff --git a/docs/spring-boot-readme.md b/docs/spring-boot-readme.md index 4069c6f67..4eb55a4b5 100644 --- a/docs/spring-boot-readme.md +++ b/docs/spring-boot-readme.md @@ -1,4 +1,4 @@ -# morphir-elm SpringBoot generator +# SpringBoot Generator [Morphir](https://github.com/finos/morphir) is a multi-language system built on a data format that captures an application's domain model and business logic in a technology agnostic manner. This document will guide you on diff --git a/docs/table-template.md b/docs/table-template.md index 42829e981..cec701c69 100644 --- a/docs/table-template.md +++ b/docs/table-template.md @@ -1,3 +1,4 @@ +# Table Template | Header col1 | Header col2 | Header col 3 | |:--------------:|:------------:|:--------------| | A1 | A2 | A3 | diff --git a/docs/testing-framework-readme.md b/docs/testing-framework-readme.md index 65eac1871..1c3764dfa 100644 --- a/docs/testing-framework-readme.md +++ b/docs/testing-framework-readme.md @@ -1,4 +1,4 @@ -## Testing Framework Guide +# Testing Framework Guide The purpose of this document is how we can use Testing Framework within developer server. ## Prerequisites