Skip to content

Commit

Permalink
Fixed all tagging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KindsonTheGenius committed Apr 20, 2023
1 parent d587649 commit b73b4fb
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 143 deletions.
4 changes: 3 additions & 1 deletion docs/cadl-doc.md
Original file line number Diff line number Diff line change
@@ -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) | | | |
Expand Down
92 changes: 46 additions & 46 deletions docs/cli-cli2-merging-docs.md

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions docs/json-schema-mappings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<br>
\
Additional reading:
* [Sample Json Schema](json-schema-sample.json)
* [Testing Strategy](json-schema-backend-testplan.md)
Expand Down Expand Up @@ -36,16 +36,16 @@ Run the ```elm morphir-elm gen -t JsonSchema``` to generate the Json Schema
**Note** - The generated schema is named `<package-name>.json` by default. But you can specify the filename
optionally for the schema using the -f flag.

<hr>

<br><br>

\
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)<br>
[1.1.1. Bool ](#bool)\
[1.1.2. Int ](#int)\
[1.1.3. Float ](#float)\
[1.1.4. Char ](#char)\
Expand Down Expand Up @@ -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)
<p> 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.
Expand Down Expand Up @@ -519,6 +519,7 @@ type alias Address =
}
```
Json Schema:

```json
"Records.Bank": {
"type": "object",
Expand All @@ -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.
74 changes: 37 additions & 37 deletions docs/morpir-developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) <br>
1. [Getting Started with Morphir](https://github.com/finos/morphir-elm/blob/main/README.md) \
2. [Overview of Morphir](#)
3. [The Morphir Architecture](#) <br>
4. [The Morphir SDK](#) <br>
5. [Morphir Commands Processing](Morphir-elm Commands Processing) <br>
1. [morphir-elm make](#) <br>
2. [morphir-elm gen](#) <br>
3. [morphir-elm test](#) <br>
4. [morphir-elm develop](#) <br>
6. [Interoperability With JavaScript](#) <br>
7. [Testing Framework](#) <br>
8. [The Morphir IR](#) <br>
1. [Overview of the Morphir IR](#) <br>
2. [Distribution](#) <br>
3. [Package](#) <br>
4. [Module](#) <br>
5. [Types](#) <br>
6. [Values](#) <br>
7. [Names](#) <br>
9. [The Morphir Frontends](#) <br>
1. [Elm Frontend](#) <br>
2. [Elm Incremental Frontend](#) <br>
10. [The Morphir Backends](#) <br>
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](#) <br>
1. [Introduction to Encoding/Decoding](#) <br>
2. [JSON Decoder Building Blocks](#) <br>
3. [Combining Decoders](#) <br>
4. [JSON Decode Pipeline](#) <br>
5. [Writing Encoders and Decoders in Elm](#) <br>
6. [Standard Codecs in Morphir](#) <br>
12. [NPM and Elm Packages](#) <br>
13. [Introduction to Combinator Parsing in Scala](#) <br>
1. [Overview of Combinator Parsing](#) <br>
2. [Parser or Basic Arithmetic Expression](#) <br>
3. [Implementing Parsers in Scala](#) <br>
4. [Regular Expressions Parser](#) <br>
5. [JSON Parser](#) <br>
6. [Low-Level Pull Parser API](#) <br>
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](#) \



Expand Down
40 changes: 20 additions & 20 deletions docs/scala-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br><br>
[1. Reading the Input IR](#) <br>
[2. Scala Code Generation](#)<br>
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**
Expand Down Expand Up @@ -37,7 +37,7 @@ fileMap =
The code generation phase consists of functions that transform the distribution into a FileMap


<br>
\

## **2. Code Generation**
The code generation consists of a number of mapping functions that map the Morphir IR types to Scala Types.
Expand All @@ -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.

<br>
\
#### 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. <br>
which returns a compilation unit. \
A compilation unit is a record type with the following fields
<br><br>
\\

```
type alias CompilationUnit =
Expand All @@ -67,13 +67,13 @@ type alias CompilationUnit =
}
```

<br>
\

#### 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.

<br>
\

#### mapFQNameToTypeRef
Maps a Morphir IR fully-qualified name to Scala type reference. It extracts the path and name
Expand All @@ -89,45 +89,45 @@ mapFQNameToTypeRef fQName =
Scala.TypeRef path (name |> Name.toTitleCase)
```

<br>
\

#### mapTypeMember
This function maps a type declaration in Morphir to a Scala member declaration.

<br>
\

#### mapModuleDefinition
This function maps a module definition to a list of Scala compilation units.

<br>
\

#### mapCustomTypeDefinition
Maps a custom type to a List of Scala member declaration

<br>
\

#### mapType
Maps a Morphir IR Type to a Scala type

<br>
\


#### mapFunctionBody
Maps an IR value defintion to a Scala value.

<br>
\


#### mapValue
Maps and IR Value type to a Scala value.

<br>
\


#### mapPattern
Maps an IR Pattern type to a Scala Pattern type

<br>
\


#### mapValueName
Expand All @@ -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.

<br>
\


#### 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.

<br>
\


#### uniqueVarName

<br>
\


## **3. Saving Generated Files**
Expand Down
16 changes: 8 additions & 8 deletions docs/scala-json-codecs-backend.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# 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.<br>
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
graph TD;
Backend-->Core;
Backend-->Features
```
The Scala backend is split into two aspects: <br>
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

Expand Down Expand Up @@ -66,16 +66,16 @@ Generates and decoder reference for the input type using the FQName


#### mapTypeDefinitionToEncoder
Type definition could be any of the following:<br>
_**Type Alias Definition**_ - maps to an encoder for record type <br>
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 <br><br>
types \\

#### mapTypeDefinitionToDecoder
Type definition could be any of the following:<br>
_**Type Alias Definition**_ - maps to an encoder for record type <br>
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 <br><br>
types \\


#### mapCustomTypeDefinitionToEncoder
Expand Down
Loading

0 comments on commit b73b4fb

Please sign in to comment.