forked from finos/morphir-elm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request finos#1096 from nwokafor-choongsaeng/irjvm
Changes for better Scala code generation
- Loading branch information
Showing
17 changed files
with
147 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"IR.Value", | ||
"IR.Module", | ||
"IR.Package", | ||
"IR.Distribution" | ||
"IR.Distribution", | ||
"IR.FormatVersion" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{- | ||
Copyright 2020 Morgan Stanley | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-} | ||
|
||
|
||
module Morphir.IR.FormatVersion exposing | ||
( VersionedDistribution | ||
, currentFormatVersion | ||
) | ||
|
||
{-| This module provides a wrapper for specifying a version of a Distribution | ||
# Type Expression | ||
@docs VersionedDistribution | ||
# VersionedDistribution | ||
@docs currentFormatVersion | ||
-} | ||
|
||
import Morphir.IR.Distribution exposing (Distribution) | ||
|
||
|
||
{-| A wrapper associates a distribution with a specific version. | ||
-} | ||
type alias VersionedDistribution = | ||
{ formatVersion : Int | ||
, distribution : Distribution | ||
} | ||
|
||
|
||
{-| This is a manually managed version number to be able to handle breaking changes in the IR format more explicitly. | ||
-} | ||
currentFormatVersion : Int | ||
currentFormatVersion = | ||
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{- | ||
Copyright 2020 Morgan Stanley | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-} | ||
|
||
|
||
module Morphir.IR.FormatVersion.Codec exposing (encodeVersionedDistribution, decodeVersionedDistribution) | ||
|
||
{-| Codecs provided for encoding and decoding a versioned distribution. | ||
# VersionedDistribution | ||
@docs encodeVersionedDistribution, decodeVersionedDistribution | ||
-} | ||
|
||
import Json.Decode as Decode | ||
import Json.Encode as Encode | ||
import Morphir.IR.Distribution exposing (Distribution) | ||
import Morphir.IR.Distribution.Codec exposing (decodeDistribution, encodeDistribution) | ||
import Morphir.IR.Distribution.CodecV1 as CodecV1 | ||
import Morphir.IR.FormatVersion exposing (currentFormatVersion) | ||
|
||
|
||
{-| Encode distribution including a version number. | ||
-} | ||
encodeVersionedDistribution : Distribution -> Encode.Value | ||
encodeVersionedDistribution distro = | ||
Encode.object | ||
[ ( "formatVersion", Encode.int currentFormatVersion ) | ||
, ( "distribution", encodeDistribution distro ) | ||
] | ||
|
||
|
||
{-| Decode distribution including a version number. | ||
-} | ||
decodeVersionedDistribution : Decode.Decoder Distribution | ||
decodeVersionedDistribution = | ||
Decode.oneOf | ||
[ Decode.field "formatVersion" Decode.int | ||
|> Decode.andThen | ||
(\formatVersion -> | ||
if formatVersion == currentFormatVersion then | ||
Decode.field "distribution" decodeDistribution | ||
|
||
else if formatVersion == 1 then | ||
Decode.field "distribution" CodecV1.decodeDistribution | ||
|
||
else | ||
Decode.fail | ||
(String.concat | ||
[ "The IR is using format version " | ||
, String.fromInt formatVersion | ||
, " but the latest format version is " | ||
, String.fromInt currentFormatVersion | ||
, ". Please regenerate it!" | ||
] | ||
) | ||
) | ||
, Decode.fail "The IR is in an old format that doesn't have a format version on it. Please regenerate it!" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters