Skip to content

Commit

Permalink
Merge branch 'remove-type-args' of github.com:anoma/juvix into remove…
Browse files Browse the repository at this point in the history
…-type-args
  • Loading branch information
lukaszcz committed Dec 8, 2022
2 parents dc38329 + 3f1dcd4 commit 9063fb2
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 83 deletions.
79 changes: 63 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
os: [ubuntu-20.04, macos-12]
ghc: ["9.2.5"]
steps:
- name: Checkout our repository
Expand Down Expand Up @@ -127,7 +127,8 @@ jobs:
enable-stack: true
stack-version: 'latest'

- name: Cache LLVM and Clang
- name: Cache LLVM and Clang (Linux)
if: runner.os == 'Linux'
id: cache-llvm
uses: actions/cache@v3
with:
Expand All @@ -136,13 +137,27 @@ jobs:
./llvm
key: ${{ runner.os }}-llvm-13

- name: Install LLVM and Clang
- name: Install LLVM and Clang (Linux)
if: runner.os == 'Linux'
uses: KyleMayes/install-llvm-action@v1
with:
version: "13.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}

- name: Build Project
- name: Set homebrew LLVM CC and LIBTOOL vars (macOS)
if: runner.os == 'macOS'
run: |
echo "CC=$(brew --prefix llvm@14)/bin/clang" >> $GITHUB_ENV
echo "LIBTOOL=$(brew --prefix llvm@14)/bin/llvm-ar" >> $GITHUB_ENV
- name: Build Project (macOS)
if: runner.os == 'macOS'
run: |
cd main
make CC=$CC LIBTOOL=$LIBTOOL build
- name: Build Project (Linux)
if: runner.os == 'Linux'
run: |
cd main
make build
Expand All @@ -152,79 +167,111 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
os: [ubuntu-20.04, macos-12]
ghc: ["9.2.5"]
steps:
- name: Checkout the main repository
uses: actions/checkout@v2
with:
path: main
submodules: recursive

- uses: actions/cache@v3
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-${{ matrix.ghc }}-stack-global-${{ hashFiles('main/stack.yaml') }}-${{ hashFiles('main/package.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-stack-global-
- uses: actions/cache@v3
name: Cache .stack-work
with:
path: main/.stack-work
key: ${{ runner.os }}-${{ matrix.ghc }}-stack-work-${{ hashFiles('main/stack.yaml') }}-${{ hashFiles('main/package.yaml') }}-${{ hashFiles('main/**/*.hs') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-stack-work-
- uses: haskell/actions/setup@v1
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
stack-version: 'latest'
- name: Cache LLVM and Clang

- name: Cache LLVM and Clang (Linux)
if: runner.os == 'Linux'
id: cache-llvm
uses: actions/cache@v3
with:
path: |
C:/Program Files/LLVM
./llvm
key: ${{ runner.os }}-llvm-13
- name: Install LLVM and Clang

- name: Install LLVM and Clang (Linux)
if: runner.os == 'Linux'
uses: KyleMayes/install-llvm-action@v1
with:
version: "13.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}

- name: Download and extract wasi-sysroot
run: |
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sysroot-15.0.tar.gz -OL
tar xfv wasi-sysroot-15.0.tar.gz
- name: Download and extract libclang_rt.builtins-wasm32-wasi
run: |
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/libclang_rt.builtins-wasm32-wasi-15.0.tar.gz -OL
tar xfv libclang_rt.builtins-wasm32-wasi-15.0.tar.gz
working-directory: ${{ env.LLVM_PATH }}
- name: Set WASI_SYSROOT_PATH
run: |
echo "WASI_SYSROOT_PATH=$GITHUB_WORKSPACE/wasi-sysroot" >> $GITHUB_ENV
- name: Setup Wasmer
uses: wasmerio/setup-wasmer@v1
- name: Test suite

- name: Set homebrew LLVM CC and LIBTOOL vars (macOS)
if: runner.os == 'macOS'
run: |
echo "CC=$(brew --prefix llvm@14)/bin/clang" >> $GITHUB_ENV
echo "LIBTOOL=$(brew --prefix llvm@14)/bin/llvm-ar" >> $GITHUB_ENV
- name: stack setup (macOS)
if: runner.os == 'macOS'
run: |
cd main
stack setup
- name: Add homebrew clang to the PATH (macOS)
if: runner.os == 'macOS'
run: |
echo "$(brew --prefix llvm@14)/bin" >> $GITHUB_PATH
- name: Test suite (macOS)
if: runner.os == 'macOS'
run: |
cd main
make CC=$CC LIBTOOL=$LIBTOOL test
- name: Test suite (linux)
id: test
if: runner.os == 'Linux'
run: |
cd main
make test
- name : Shell tests
- name : Shell tests (Linux)
id: shell-tests
if: matrix.os == 'ubuntu-latest'
if: runner.os == 'Linux'
run : |
cd main
echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH
make test-shell
docs:
needs: build
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-20.04]
ghc: ["9.2.5"]
runs-on: ${{ matrix.os }}
steps:
Expand Down
8 changes: 7 additions & 1 deletion app/Commands/Dev/Asm/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Commands.Dev.Asm.Validate where

import Commands.Base
import Commands.Dev.Asm.Validate.Options
import Juvix.Compiler.Asm.Pretty qualified as Asm
import Juvix.Compiler.Asm.Transformation.Validate qualified as Asm
import Juvix.Compiler.Asm.Translation.FromSource qualified as Asm

Expand All @@ -15,7 +16,12 @@ runCommand opts = do
Just err ->
exitJuvixError (JuvixError err)
Nothing ->
exitMsg ExitSuccess "validation succeeded"
if
| opts ^. asmValidateNoPrint ->
exitMsg ExitSuccess "validation succeeded"
| otherwise -> do
renderStdOut (Asm.ppOutDefault tab tab)
exitMsg ExitSuccess ""
where
file :: FilePath
file = opts ^. asmValidateInputFile . pathPath
10 changes: 8 additions & 2 deletions app/Commands/Dev/Asm/Validate/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ module Commands.Dev.Asm.Validate.Options where

import CommonOptions

newtype AsmValidateOptions = AsmValidateOptions
{ _asmValidateInputFile :: Path
data AsmValidateOptions = AsmValidateOptions
{ _asmValidateInputFile :: Path,
_asmValidateNoPrint :: Bool
}
deriving stock (Data)

Expand All @@ -12,4 +13,9 @@ makeLenses ''AsmValidateOptions
parseAsmValidateOptions :: Parser AsmValidateOptions
parseAsmValidateOptions = do
_asmValidateInputFile <- parseInputJuvixAsmFile
_asmValidateNoPrint <-
switch
( long "no-print"
<> help "Don't pretty print the file"
)
pure AsmValidateOptions {..}
10 changes: 0 additions & 10 deletions src/Juvix/Compiler/Asm/Extra/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ mkTypeFun args tgt = case args of
[] -> tgt
a : args' -> TyFun (TypeFun (a :| args') tgt)

typeArgs :: Type -> [Type]
typeArgs = \case
TyFun x -> toList (x ^. typeFunArgs)
_ -> []

typeTarget :: Type -> Type
typeTarget ty = case ty of
TyFun x -> x ^. typeFunTarget
_ -> ty

unfoldType :: Type -> ([Type], Type)
unfoldType ty = (typeArgs ty, typeTarget ty)

Expand Down
10 changes: 10 additions & 0 deletions src/Juvix/Compiler/Asm/Language/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,13 @@ instance HasAtomicity Type where
TyInductive x -> atomicity x
TyConstr x -> atomicity x
TyFun x -> atomicity x

typeArgs :: Type -> [Type]
typeArgs = \case
TyFun x -> toList (x ^. typeFunArgs)
_ -> []

typeTarget :: Type -> Type
typeTarget ty = case ty of
TyFun x -> x ^. typeFunTarget
_ -> ty
Loading

0 comments on commit 9063fb2

Please sign in to comment.