-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
eeecef7
commit b707e44
Showing
11 changed files
with
354 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ dist | |
.idea | ||
.metals/ | ||
morphir-ir.json | ||
generated/ | ||
out/ |
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 @@ | ||
version = "2.7.4" |
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 @@ | ||
0.9.5 |
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 @@ | ||
version = "2.7.4" |
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,9 @@ | ||
// build.sc | ||
import mill._, scalalib._ | ||
|
||
object generated extends Module { | ||
object refModel extends ScalaModule { | ||
def scalaVersion = "2.11.12" | ||
def ivyDeps = Agg(ivy"org.morphir::morphir-sdk-core:0.6.1") | ||
} | ||
} |
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,48 @@ | ||
#!/usr/bin/env sh | ||
|
||
# This is a wrapper script, that automatically download mill from GitHub release pages | ||
# You can give the required mill version with MILL_VERSION env variable | ||
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION | ||
DEFAULT_MILL_VERSION=0.7.0 | ||
|
||
set -e | ||
|
||
if [ -z "$MILL_VERSION" ] ; then | ||
if [ -f ".mill-version" ] ; then | ||
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" | ||
elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then | ||
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) | ||
else | ||
MILL_VERSION=$DEFAULT_MILL_VERSION | ||
fi | ||
fi | ||
|
||
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then | ||
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download" | ||
else | ||
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download" | ||
fi | ||
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" | ||
|
||
version_remainder="$MILL_VERSION" | ||
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" | ||
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" | ||
|
||
if [ ! -x "$MILL_EXEC_PATH" ] ; then | ||
mkdir -p $MILL_DOWNLOAD_PATH | ||
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then | ||
ASSEMBLY="-assembly" | ||
fi | ||
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download | ||
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}" | ||
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" | ||
chmod +x "$DOWNLOAD_FILE" | ||
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" | ||
unset DOWNLOAD_FILE | ||
unset MILL_DOWNLOAD_URL | ||
fi | ||
|
||
unset MILL_DOWNLOAD_PATH | ||
unset MILL_VERSION | ||
|
||
exec $MILL_EXEC_PATH "$@" |
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,95 @@ | ||
@echo off | ||
|
||
rem This is a wrapper script, that automatically download mill from GitHub release pages | ||
rem You can give the required mill version with --mill-version parameter | ||
rem If no version is given, it falls back to the value of DEFAULT_MILL_VERSION | ||
rem | ||
rem Project page: https://github.com/lefou/millw | ||
rem | ||
rem If you want to improve this script, please also contribute your changes back! | ||
rem | ||
rem Licensed under the Apache License, Version 2.0 | ||
|
||
rem setlocal seems to be unavailable on Windows 95/98/ME | ||
rem but I don't think we need to support them in 2019 | ||
setlocal enabledelayedexpansion | ||
|
||
set "DEFAULT_MILL_VERSION=0.7.3" | ||
|
||
rem %~1% removes surrounding quotes | ||
if [%~1%]==[--mill-version] ( | ||
rem shift command doesn't work within parentheses | ||
if not [%~2%]==[] ( | ||
set MILL_VERSION=%~2% | ||
set "STRIP_VERSION_PARAMS=true" | ||
) else ( | ||
echo You specified --mill-version without a version. | ||
echo Please provide a version that matches one provided on | ||
echo https://github.com/lihaoyi/mill/releases | ||
exit /b 1 | ||
) | ||
) | ||
|
||
if [!MILL_VERSION!]==[] ( | ||
if exist .mill-version ( | ||
set /p MILL_VERSION=<.mill-version | ||
) | ||
) | ||
|
||
if [!MILL_VERSION!]==[] ( | ||
set MILL_VERSION=%DEFAULT_MILL_VERSION% | ||
) | ||
|
||
set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download | ||
|
||
rem without bat file extension, cmd doesn't seem to be able to run it | ||
set MILL=%MILL_DOWNLOAD_PATH%\!MILL_VERSION!.bat | ||
|
||
if not exist "%MILL%" ( | ||
set VERSION_PREFIX=%MILL_VERSION:~0,4% | ||
set DOWNLOAD_SUFFIX=-assembly | ||
if [!VERSION_PREFIX!]==[0.0.] set DOWNLOAD_SUFFIX= | ||
if [!VERSION_PREFIX!]==[0.1.] set DOWNLOAD_SUFFIX= | ||
if [!VERSION_PREFIX!]==[0.2.] set DOWNLOAD_SUFFIX= | ||
if [!VERSION_PREFIX!]==[0.3.] set DOWNLOAD_SUFFIX= | ||
if [!VERSION_PREFIX!]==[0.4.] set DOWNLOAD_SUFFIX= | ||
set VERSION_PREFIX= | ||
|
||
rem there seems to be no way to generate a unique temporary file path (on native Windows) | ||
set DOWNLOAD_FILE=%MILL%.tmp | ||
|
||
echo Downloading mill %MILL_VERSION% from https://github.com/lihaoyi/mill/releases ... | ||
|
||
rem curl is bundled with recent Windows 10 | ||
rem but I don't think we can expect all the users to have it in 2019 | ||
rem bitadmin seems to be available on Windows 7 | ||
rem without /dynamic, github returns 403 | ||
rem bitadmin is sometimes needlessly slow but it looks better with /priority foreground | ||
if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%" | ||
bitsadmin /transfer millDownloadJob /dynamic /priority foreground "https://github.com/lihaoyi/mill/releases/download/%MILL_VERSION%/%MILL_VERSION%!DOWNLOAD_SUFFIX!" "!DOWNLOAD_FILE!" | ||
if not exist "!DOWNLOAD_FILE!" ( | ||
echo Could not download mill %MILL_VERSION% | ||
exit 1 | ||
) | ||
|
||
move /y "!DOWNLOAD_FILE!" "%MILL%" | ||
|
||
set DOWNLOAD_FILE= | ||
set DOWNLOAD_SUFFIX= | ||
) | ||
|
||
set MILL_DOWNLOAD_PATH= | ||
set MILL_VERSION= | ||
|
||
set MILL_PARAMS=%* | ||
|
||
if defined STRIP_VERSION_PARAMS ( | ||
for /f "tokens=1-2*" %%a in ("%*") do ( | ||
rem strip %%a - It's the "--mill-version" option. | ||
rem strip %%b - it's the version number that comes after the option. | ||
rem keep %%c - It's the remaining options. | ||
set MILL_PARAMS=%%c | ||
) | ||
) | ||
|
||
"%MILL%" -i %MILL_PARAMS% |
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
175 changes: 175 additions & 0 deletions
175
tests-integration/reference-model/src/Morphir/Reference/Model/Issues/Issue333.elm
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,175 @@ | ||
module Morphir.Reference.Model.Issues.Issue333 exposing (..) | ||
|
||
|
||
type Month | ||
= January | ||
| February | ||
| March | ||
| April | ||
| May | ||
| June | ||
| July | ||
| August | ||
| September | ||
| October | ||
| November | ||
| December | ||
|
||
|
||
type MonthParseError | ||
= InvalidMonth Int | ||
|
||
|
||
type alias RawLocalDate = | ||
{ year : Int | ||
, month : Int | ||
, day : Int | ||
} | ||
|
||
|
||
type alias ValidLocalDate = | ||
{ year : Int | ||
, month : Month | ||
, day : Int | ||
} | ||
|
||
|
||
type LocalDate | ||
= Invalid RawLocalDate | ||
| Valid ValidLocalDate | ||
|
||
|
||
monthNumber : Month -> Int | ||
monthNumber month = | ||
case month of | ||
January -> | ||
1 | ||
|
||
February -> | ||
2 | ||
|
||
March -> | ||
3 | ||
|
||
April -> | ||
4 | ||
|
||
May -> | ||
5 | ||
|
||
June -> | ||
6 | ||
|
||
July -> | ||
7 | ||
|
||
August -> | ||
8 | ||
|
||
September -> | ||
9 | ||
|
||
October -> | ||
10 | ||
|
||
November -> | ||
11 | ||
|
||
December -> | ||
12 | ||
|
||
|
||
fromInt : Int -> Maybe Month | ||
fromInt month = | ||
case month of | ||
1 -> | ||
Just January | ||
|
||
2 -> | ||
Just February | ||
|
||
3 -> | ||
Just March | ||
|
||
4 -> | ||
Just April | ||
|
||
5 -> | ||
Just May | ||
|
||
6 -> | ||
Just June | ||
|
||
7 -> | ||
Just July | ||
|
||
8 -> | ||
Just August | ||
|
||
9 -> | ||
Just September | ||
|
||
10 -> | ||
Just October | ||
|
||
11 -> | ||
Just November | ||
|
||
12 -> | ||
Just December | ||
|
||
_ -> | ||
Nothing | ||
|
||
|
||
convertFromInt : Int -> Result MonthParseError Month | ||
convertFromInt month = | ||
case month of | ||
1 -> | ||
Ok January | ||
|
||
2 -> | ||
Ok February | ||
|
||
3 -> | ||
Ok March | ||
|
||
4 -> | ||
Ok April | ||
|
||
5 -> | ||
Ok May | ||
|
||
6 -> | ||
Ok June | ||
|
||
7 -> | ||
Ok July | ||
|
||
8 -> | ||
Ok August | ||
|
||
9 -> | ||
Ok September | ||
|
||
10 -> | ||
Ok October | ||
|
||
11 -> | ||
Ok November | ||
|
||
12 -> | ||
Ok December | ||
|
||
m -> | ||
InvalidMonth m |> Err | ||
|
||
|
||
fold : (RawLocalDate -> out) -> (ValidLocalDate -> out) -> LocalDate -> out | ||
fold whenInvalid whenValid date = | ||
case date of | ||
Valid validDate -> | ||
whenValid validDate | ||
|
||
Invalid rawDate -> | ||
whenInvalid rawDate |