Skip to content

Commit 006a01a

Browse files
Updated decorations documentations. Replaced Cadl with Typespec
1 parent 0249575 commit 006a01a

File tree

5 files changed

+52
-131
lines changed

5 files changed

+52
-131
lines changed

docs/cadl-doc.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
id: morphir-cadl-mapping
3-
title: Morphir-Cadl Mapping
2+
id: morphir-typespec-mapping
3+
title: Morphir-TypeSpec Mapping
44
---
55

6-
# Morphir-Cadl Mapping
7-
## [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
8-
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.
6+
# Morphir-Typespec Mapping
7+
## [Morphir](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) to [TypeSpec Type](https://microsoft.github.io/typespec/language-basics/type-relations/) Mappings
8+
This is a documentation of the mapping strategy from Morphir types to Typespec types. This document describes how types in Morphir Models are represented in Typespec.
99
Below is a quick overview of the mapping in the table:
1010

1111

1212

13-
| | Type | Cadl Type | Comment |
13+
| | Type | TypeSpec Type | Comment |
1414
|-------------------------------------------------------|--------------------------------------------|-----------------------------------|-----------------------------------------------------|
1515
| [Basic Types](#basic-types) | | | |
1616
| | `Bool` | `boolean` | |
@@ -47,7 +47,7 @@ Elm:
4747
type alias IsApplicable =
4848
Bool
4949
```
50-
Cadl
50+
TypeSpec
5151
```
5252
alias IsApplicable = boolean;
5353
```
@@ -61,13 +61,13 @@ Elm:
6161
type alias Foo =
6262
Int
6363
```
64-
Cadl:
64+
TypeSpec:
6565
```cadl
6666
alias Foo = int64;
6767
```
6868
***Note:***
6969

70-
The `integer` type assignment is valid in Cadl but would default to **object** when dealing with the **OAS emitters**.
70+
The `integer` type assignment is valid in TypeSpec but would default to **object** when dealing with the **OAS emitters**.
7171

7272
##### [Float](https://package.elm-lang.org/packages/elm/core/latest/Basics#Float)
7373
The `Float` type; floating point number, in morphir maps directly to the `float` type in CADL.
@@ -77,13 +77,13 @@ Elm:
7777
type alias Pi =
7878
Float
7979
```
80-
Cadl:
80+
TypeSpec:
8181
```cadl
8282
alias Pi = float64;
8383
```
8484
***Note:***>
8585

86-
The `float` type assignment is valid in Cadl but would default to **object** when dealing with the **OAS emitters**.
86+
The `float` type assignment is valid in TypeSpec but would default to **object** when dealing with the **OAS emitters**.
8787

8888
##### [String](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-SDK-String)
8989
The `String` type; a sequence of characters, in morphir maps directly to `string` type in CADL.
@@ -93,20 +93,20 @@ Elm:
9393
type alias Address =
9494
String
9595
```
96-
Cadl:
96+
TypeSpec:
9797
```cadl
9898
alias Address = string ;
9999
```
100100

101101
##### [Char](https://package.elm-lang.org/packages/elm/core/latest/Char)
102-
The `char` type is a single character type in morphir and doesn't exist in Cadl. An alternative mapping is the `string` type.
102+
The `char` type is a single character type in morphir and doesn't exist in TypeSpec. An alternative mapping is the `string` type.
103103

104104
Elm:
105105
``` elm
106106
type alias AccountGroup =
107107
Char
108108
```
109-
Cadl:
109+
TypeSpec:
110110
```cadl
111111
alias AccountGroup = string;
112112
```
@@ -122,7 +122,7 @@ import Morphir.SDK.Decimal exposing (Decimal)
122122
type alias Price =
123123
Decimal
124124
```
125-
Cadl:
125+
TypeSpec:
126126
```cadl
127127
alias Price = string
128128
```
@@ -136,7 +136,7 @@ import Morphir.SDK.LocalDate exposing (LocalDate)
136136
type alias DateOfBirth =
137137
LocalDate
138138
```
139-
Cadl:
139+
TypeSpec:
140140
```cadl
141141
alias dateOfBirth = plainDate;
142142
```
@@ -150,7 +150,7 @@ import Morphir.SDK.LocalTime exposing (LocalTime)
150150
type alias CurrentTime =
151151
LocalTime
152152
```
153-
Cadl:
153+
TypeSpec:
154154
```cadl
155155
alias currentTime = plainTime;
156156
```
@@ -166,13 +166,13 @@ import Morphir.SDK.Month exposing (Month)
166166
type alias CurrentMonth =
167167
Month
168168
```
169-
Cadl:
169+
TypeSpec:
170170
```cadl
171171
alias purchaseMonth = string;
172172
```
173173

174174
##### [Optional Values(Maybe)](https://package.elm-lang.org/packages/elm/core/latest/Maybe)
175-
The `maybe` type in morphir represents a type that may or may not exist. The type could exist as a standalone type or a field type in a record and both scenarios are supported directly in Cadl.
175+
The `maybe` type in morphir represents a type that may or may not exist. The type could exist as a standalone type or a field type in a record and both scenarios are supported directly in TypeSpec.
176176

177177
1. `maybe` as a standalone type, is presented in cadl as a union of the type or null using the pipe `|` syntax.
178178

@@ -181,12 +181,12 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ
181181
type alias Foo =
182182
Maybe Int
183183
```
184-
Cadl:
184+
TypeSpec:
185185
```cadl
186186
alias Foo = int64 | null
187187
```
188188
189-
2. `maybe` as a field type in a record, is represented as `optional field` in a model in cadl using `optional field` `?:` syntax.
189+
2. `maybe` as a field type in a record, is represented as `optional field` in a model in TypeSpec using `optional field` `?:` syntax.
190190
191191
Elm:
192192
```elm
@@ -196,7 +196,7 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ
196196
, baz: Maybe String
197197
}
198198
```
199-
Cadl:
199+
TypeSpec:
200200
```cadl
201201
model FooBarBaz {
202202
foo : int64;
@@ -215,7 +215,7 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ
215215
, baz: Maybe (Maybe String)
216216
}
217217
```
218-
Cadl:
218+
TypeSpec:
219219
```cadl
220220
model FooBarBaz {
221221
foo : int64;
@@ -238,7 +238,7 @@ type alias Foo =
238238
type alias Bar a =
239239
List a
240240
```
241-
Cadl:
241+
TypeSpec:
242242
```cadl
243243
alias Foo = Array<int64>;
244244
@@ -256,7 +256,7 @@ type alias Foo =
256256
type alias Bar a =
257257
Set a
258258
```
259-
Cadl:
259+
TypeSpec:
260260
```cadl
261261
alias Foo = Array<int64>;
262262
@@ -275,7 +275,7 @@ type alias Foo =
275275
type alias Bar a b =
276276
Dict a b
277277
```
278-
Cadl
278+
TypeSpec
279279
```cadl
280280
alias Foo = Array<[string,int64]>;
281281
@@ -291,7 +291,7 @@ Elm:
291291
type alias Foo e v=
292292
Result e v
293293
```
294-
Cadl:
294+
TypeSpec:
295295
```cadl
296296
alias Foo<E,V> = ["Err", E] | ["Ok", V];
297297
```
@@ -308,7 +308,7 @@ type alias Foo =
308308
type alias Bar a b =
309309
( a, b )
310310
```
311-
Cadl:
311+
TypeSpec:
312312
```cadl
313313
alias Foo = [string, int64];
314314
@@ -326,7 +326,7 @@ type alias FooBarBaz =
326326
, baz: Float
327327
}
328328
```
329-
Cadl:
329+
TypeSpec:
330330
```cadl
331331
model FooBarBaz {
332332
foo: integer,
@@ -348,7 +348,7 @@ type FooBarBaz
348348
| Bar
349349
```
350350

351-
Cadl:
351+
TypeSpec:
352352
```cadl
353353
alias FooBarBaz = ["Foo", int64] | ["Bar", string] | "Baz";
354354
```
@@ -362,7 +362,7 @@ type Currency
362362
| GBP
363363
| GHS
364364
```
365-
Cadl:
365+
TypeSpec:
366366
```
367367
enum Currency {
368368
USD,
@@ -372,20 +372,20 @@ enum Currency {
372372
```
373373

374374

375-
# Mapping [Cadl feature concepts](https://microsoft.github.io/cadl/language-basics/overview) to [Morphir](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type)
375+
# Mapping [TypeSpec feature concepts](https://microsoft.github.io/typespec/language-basics/overview) to [Morphir](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type)
376376

377377
---
378378

379379
| | CADL Type | Morphir Type | Comment |
380380
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
381-
| [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 |
382-
| [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 |
383-
| [Enums](https://microsoft.github.io/cadl/language-basics/enums) | `enum Direction {East; West; North; South}` | `type Direction `<br/> `= East` <code>&#124;</code> `West` <code>&#124;</code> `North` <code>&#124;</code> `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 |
381+
| [Namespaces](https://microsoft.github.io/typespec/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 |
382+
| [Models](https://microsoft.github.io/typespec/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 |
383+
| [Enums](https://microsoft.github.io/typespec/language-basics/enums) | `enum Direction {East; West; North; South}` | `type Direction `<br/> `= East` <code>&#124;</code> `West` <code>&#124;</code> `North` <code>&#124;</code> `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 |
384384
| [Union Type](https://package.elm-lang.org/packages/finos/morphir-elm/18.1.0/Morphir-IR-Type) |||
385385
| | -<span> Unnamed Union </span> <br /> `alias Breed = Breagle` <code>&#124;</code> `GermanShepherd` <code>&#124;</code> `GoldenRetriever` <br /> <span>- Named Union </span> <br /> `union Breed {`<br /> &ensp; `beagle: Beagle,` <br /> &ensp; `shepherd: GermanShepherd.` <br /> &ensp; `retiever: GoldenRetriever`<br /> `}` | `type Breed` <br /> &ensp; `= Beagle Beagle`<br /> &ensp; &ensp; <code>&#124;</code> `Shepherd GermanShepherd ` <br /> &ensp; &ensp; <code>&#124;</code> `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).` <br /> <span> NB: unnamed Unions are currently not supported in morphir </span> |
386386

387387

388-
## [Type Relations](https://microsoft.github.io/cadl/language-basics/type-relations)
388+
## [Type Relations](https://microsoft.github.io/typespec/language-basics/type-relations)
389389

390390
##### Boolean
391391
Boolean in CADL, maps to [`bool`](https://package.elm-lang.org/packages/elm/core/latest/Basics#Bool), a `true` or `false` value in Morphir.

docs/custom-attributes.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)