You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cadl-doc.md
+36-36Lines changed: 36 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
2
-
id: morphir-cadl-mapping
3
-
title: Morphir-Cadl Mapping
2
+
id: morphir-typespec-mapping
3
+
title: Morphir-TypeSpec Mapping
4
4
---
5
5
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.
9
9
Below is a quick overview of the mapping in the table:
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.
176
176
177
177
1.`maybe` as a standalone type, is presented in cadl as a union of the type or null using the pipe `|` syntax.
178
178
@@ -181,12 +181,12 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ
181
181
type alias Foo=
182
182
MaybeInt
183
183
```
184
-
Cadl:
184
+
TypeSpec:
185
185
```cadl
186
186
alias Foo = int64 | null
187
187
```
188
188
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.
190
190
191
191
Elm:
192
192
```elm
@@ -196,7 +196,7 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ
196
196
, baz: Maybe String
197
197
}
198
198
```
199
-
Cadl:
199
+
TypeSpec:
200
200
```cadl
201
201
model FooBarBaz {
202
202
foo : int64;
@@ -215,7 +215,7 @@ The `maybe` type in morphir represents a type that may or may not exist. The typ
215
215
, baz:Maybe(MaybeString)
216
216
}
217
217
```
218
-
Cadl:
218
+
TypeSpec:
219
219
```cadl
220
220
model FooBarBaz{
221
221
foo : int64;
@@ -238,7 +238,7 @@ type alias Foo =
238
238
type alias Bar a =
239
239
List a
240
240
```
241
-
Cadl:
241
+
TypeSpec:
242
242
```cadl
243
243
alias Foo = Array<int64>;
244
244
@@ -256,7 +256,7 @@ type alias Foo =
256
256
type alias Bar a =
257
257
Set a
258
258
```
259
-
Cadl:
259
+
TypeSpec:
260
260
```cadl
261
261
alias Foo = Array<int64>;
262
262
@@ -275,7 +275,7 @@ type alias Foo =
275
275
type alias Bar a b =
276
276
Dict a b
277
277
```
278
-
Cadl
278
+
TypeSpec
279
279
```cadl
280
280
alias Foo = Array<[string,int64]>;
281
281
@@ -291,7 +291,7 @@ Elm:
291
291
type alias Foo e v=
292
292
Result e v
293
293
```
294
-
Cadl:
294
+
TypeSpec:
295
295
```cadl
296
296
alias Foo<E,V> = ["Err", E] | ["Ok", V];
297
297
```
@@ -308,7 +308,7 @@ type alias Foo =
308
308
type alias Bar a b =
309
309
( a, b )
310
310
```
311
-
Cadl:
311
+
TypeSpec:
312
312
```cadl
313
313
alias Foo = [string, int64];
314
314
@@ -326,7 +326,7 @@ type alias FooBarBaz =
326
326
, baz:Float
327
327
}
328
328
```
329
-
Cadl:
329
+
TypeSpec:
330
330
```cadl
331
331
model FooBarBaz {
332
332
foo: integer,
@@ -348,7 +348,7 @@ type FooBarBaz
348
348
|Bar
349
349
```
350
350
351
-
Cadl:
351
+
TypeSpec:
352
352
```cadl
353
353
alias FooBarBaz = ["Foo", int64] | ["Bar", string] | "Baz";
354
354
```
@@ -362,7 +362,7 @@ type Currency
362
362
|GBP
363
363
|GHS
364
364
```
365
-
Cadl:
365
+
TypeSpec:
366
366
```
367
367
enum Currency {
368
368
USD,
@@ -372,20 +372,20 @@ enum Currency {
372
372
```
373
373
374
374
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)
|[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>|</code> `West` <code>|</code> `North` <code>|</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>|</code> `West` <code>|</code> `North` <code>|</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 |
|| -<span> Unnamed Union </span> <br /> `alias Breed = Breagle` <code>|</code> `GermanShepherd` <code>|</code> `GoldenRetriever` <br /> <span>- Named Union </span> <br /> `union Breed {`<br />  `beagle: Beagle,` <br />  `shepherd: GermanShepherd.` <br />  `retiever: GoldenRetriever`<br /> `}`|`type Breed` <br />  `= Beagle Beagle`<br />    <code>|</code> `Shepherd GermanShepherd ` <br />    <code>|</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> |
0 commit comments