Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into main
Browse files Browse the repository at this point in the history
* origin/master: (25 commits)
  AddRAN: missing fields in functionMeta record
  src: HaskellFrontend
  change package versions
  Passes: Access patterns, update GHC version to 9.4.6 in CI
  fix L1 test
  fix
  Tests: Fix L1 Typecheck case to fix CI error
  Fix ghc 9.6.2 build error
  Passes: CallGraph
  Passes: Support for Definition Use Chains
  Passes: Control Flow Graph
  Update devcontainers
  Update GHC to v9.6.2
  Disable tests that build with GHC 8.6.5 and 8.4.4
  Mark failing tests
  Allow GHC 8.6.5 and 8.4.4 to fail
  Use GCC11 and use ghcup to install GHC
  Use Ubuntu 22.04 on CI
  Minor tweak to the workflow file
  Tailrec: linked list examples and results
  ...
  • Loading branch information
ckoparkar committed Aug 22, 2023
2 parents 39ab2f0 + 5827f62 commit ee482b0
Show file tree
Hide file tree
Showing 48 changed files with 10,171 additions and 5,128 deletions.
55 changes: 40 additions & 15 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/ubuntu/.devcontainer/base.Dockerfile
# Ubuntu 22
ARG VARIANT="jammy"
ARG DEBIAN_FRONTEND=noninteractive
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} as base
ENV USERNAME=vscode

# [Choice] Ubuntu version: bionic, focal
ARG VARIANT="bionic"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& sudo apt-get -y install --no-install-recommends software-properties-common \
&& sudo add-apt-repository -y ppa:plt/racket \
&& sudo add-apt-repository -y ppa:hvr/ghc \
&& sudo apt-get -y install --no-install-recommends libgc-dev libgmp-dev \
gcc-7 uthash-dev racket \
ghc-9.0.1 cabal-install-3.4 vim
RUN curl -sSL https://get.haskellstack.org/ | sh
ENV PATH /opt/ghc/bin:/opt/cabal/bin:$PATH
RUN sudo ln -sf /usr/bin/gcc-7 /usr/bin/gcc
# install dependencies
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
apt-get update && \
apt-get -y install --no-install-recommends software-properties-common && \
add-apt-repository -y ppa:plt/racket && \
apt-get -y install --no-install-recommends \
libgc-dev \
libgmp-dev \
racket \
uthash-dev \
vim

# update path
USER ${USERNAME}
WORKDIR /home/${USERNAME}
ENV PATH="/home/${USERNAME}/.local/bin:/home/${USERNAME}/.cabal/bin:/home/${USERNAME}/.ghcup/bin:$PATH"
RUN echo "export PATH=${PATH}" >> /home/${USERNAME}/.profile

# install ghcup
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

ARG GHC=9.0.2
ARG CABAL=3.4
ARG STACK=2.9.3
ARG HLS=recommended

# install GHC, cabal and HLS
RUN \
ghcup install ghc ${GHC} --set && \
ghcup install cabal ${CABAL} --set && \
ghcup install stack ${STACK} --set && \
ghcup install hls ${HLS} --set

# update cabal package list
RUN cabal update
8 changes: 3 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic
"args": { "VARIANT": "bionic" }
},
"dockerfile": "Dockerfile",
"args": { "VARIANT": "jammy" }
},

// Set *default* container specific settings.json values on container create.
"settings": {},
Expand All @@ -23,5 +22,4 @@

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"

}
23 changes: 9 additions & 14 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.4.3
- compiler: ghc-9.4.6
compilerKind: ghc
compilerVersion: 9.4.3
compilerVersion: 9.4.6
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.5
- compiler: ghc-9.4.5
compilerKind: ghc
compilerVersion: 9.2.5
compilerVersion: 9.4.5
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.8
compilerKind: ghc
compilerVersion: 9.2.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand All @@ -53,16 +58,6 @@ jobs:
compilerVersion: 8.8.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: ghcup
allow-failure: true
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: ghcup
allow-failure: true
fail-fast: false
steps:
- name: apt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-gibbon-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: ghc and cabal
env:
HCKIND: ghc
HCVER: 9.0.1
HCVER: 9.4.6
run: |
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
Expand All @@ -30,7 +30,7 @@ jobs:
echo "$HOME/.ghcup/bin/" >> $GITHUB_PATH
- name: versions
run: |
ghc --version
$HC --version
racket --version
gcc --version
stack --version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
data Ast
= Val Bool
| Not Ast
| Or Ast Ast
| And Ast Ast

--eval :: Ast -> Bool
--eval x = case x of
-- Val b -> b
-- Not e -> if eval e then False else True
-- Or e1 e2 ->
-- if eval e1 then True
-- else eval e2
-- And e1 e2 ->
-- if eval e1 then eval e2
-- else False

--simplify :: Ast -> Ast
--simplify x = Val (eval x)

evalR :: Ast -> Bool
{-# ANN evalR Or #-}
{-# ANN evalR And #-}
evalR x = case x of
Val b -> b
Not e -> if evalR e then False else True
Or e1 e2 ->
if evalR e2 then True
else evalR e1
And e1 e2 ->
if evalR e2 then evalR e1
else False

simplifyR :: Ast -> Ast
simplifyR x = Val (evalR x)

mkRandTree :: Int -> Ast
mkRandTree n =
if n > 0 then
let m = mod rand 3 in
if m == 0 then Not (mkRandTree (n-1))
else if m == 1 then And (mkRandTree (n-1)) (mkRandTree (n-1))
else Or (mkRandTree (n-1)) (mkRandTree (n-1))
else Val (mod rand 2 == 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Eval

gibbon_main =
let
n = 45
t = mkRandTree n

-- _ = iterate (eval t)
s = iterate (evalR t)
in ()

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
type Text = Vector Char

data Content = Str Text Content
| End

data List = Snoc (List) Content
| Nil


mkContent :: Int -> Content
mkContent len = if len <= 0 then End
else Str "abcdef" (mkContent (len - 1))


mkSnocList :: Int -> List
mkSnocList len = if len <= 0
then Nil
else let
rst = mkSnocList (len - 1)
val = mkContent 100
in Snoc rst val

getLengthSnoc :: List -> Int
{-# ANN getLengthSnoc Snoc #-}
getLengthSnoc lst = case lst of
Snoc rst val -> 1 + getLengthSnoc rst
Nil -> 0


gibbon_main =
let snocList = mkSnocList 1000000
--consList = mkConsList 100000
l1 = iterate (getLengthSnoc snocList)
--l2 = getLengthCons consList
_ = printsym (quote "Length Snoc: ")
_ = printint l1
_ = printsym (quote "NEWLINE")
--_ = printsym (quote "Length Cons: ")
--_ = printint l2
--_ = printsym (quote "NEWLINE")
in ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
type Text = Vector Char

data Content = Str Text Content
| End

data List = Cons Content (List)
| Nil


mkContent :: Int -> Content
mkContent len = if len <= 0 then End
else Str "abcdef" (mkContent (len - 1))


mkConsList :: Int -> List
mkConsList len = if len <= 0
then Nil
else let
--val = mkContent 100
rst = mkConsList (len - 1)
val = mkContent 100
in Cons val rst

getLengthCons :: List -> Int
{-# ANN getLengthCons Cons #-}
getLengthCons lst = case lst of
Cons val rst -> getLengthCons rst + 1
Nil -> 0



gibbon_main =
let --snocList = mkSnocList 90000
consList = mkConsList 3000000
--l1 = getLengthSnoc snocList
l2 = iterate (getLengthCons consList)
--_ = printsym (quote "Length Snoc: ")
--_ = printint l1
--_ = printsym (quote "NEWLINE")
_ = printsym (quote "Length Cons: ")
_ = printint l2
_ = printsym (quote "NEWLINE")
in ()
46 changes: 28 additions & 18 deletions gibbon-compiler/gibbon.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ copyright: Copyright 2016-2022 Ryan Newton and contributors
category: Compilers/Interpreters
extra-source-files: README.md
build-type: Simple

tested-with: GHC==9.4.3
, GHC==9.2.5
extra-source-files: README.md, cbits/rts.c
cabal-version: >=1.10
tested-with: GHC==9.4.6
, GHC==9.4.5
, GHC==9.2.8
, GHC==9.0.2
, GHC==8.10.7
, GHC==8.8.4
, GHC==8.6.5
, GHC==8.4.4

flag LLVM_ENABLED
description: Enable LLVM backend
Expand Down Expand Up @@ -88,20 +88,27 @@ library
Gibbon.Passes.RearrangeFree
Gibbon.Passes.Codegen
Gibbon.Passes.CalculateBounds
Gibbon.Passes.ControlFlowGraph
Gibbon.Passes.DefinitionUseChains
Gibbon.Passes.CallGraph
Gibbon.Passes.AccessPatternsAnalysis
Gibbon.Passes.SolveLayoutConstrs

other-extensions: DeriveDataTypeable CPP

build-depends: base >= 4.11 && < 5
, bytestring >= 0.10.8 && < 0.12
, text >= 1.2 && < 3
, process >= 1.4 && < 2
, bytestring >= 0.10.8.1 && < 1
, text >= 1.2.3 && < 3
, process >= 1.4.3 && < 2
, filepath >= 1.4.1 && < 2
, directory >= 1.3 && < 2
, containers >= 0.5 && < 0.7
, deepseq >= 1.4 && < 1.5
, mtl >= 2.2 && < 3
, transformers >= 0.5 && < 1
, clock >= 0.8 && < 1
, containers >= 0.5.8 && < 0.7
, deepseq >= 1.4.2 && < 1.5
, mtl >= 2.2.1 && < 3
, transformers >= 0.5.2 && < 1
, clock >= 0.7.1 && < 1
, random >= 1.1 && < 1.3
, recursion-schemes >= 5 && < 6
, recursion-schemes >= 5.1 && < 6
, vector >= 0.12 && < 0.14
, tuple >= 0.3 && < 1
-- Parsers:
Expand All @@ -113,10 +120,13 @@ library
, srcloc >= 0.6 && < 1
, symbol >= 0.2.4 && < 1
-- Pretty printers:
, pretty >= 1.1.1 && < 1.2
, GenericPretty >= 1.2 && < 2
, language-c-quote >= 0.12 && < 1
, mainland-pretty >= 0.6 && < 1
, pretty >= 1.1.1.3 && < 1.2
, GenericPretty >= 1.2.1 && < 2
, language-c-quote >= 0.12.1 && < 1
, mainland-pretty >= 0.6.1 && < 1
, language-python >= 0.5.0 && <= 0.5.8
, timeit >= 0.9 && <= 2.0
, time >= 1 && <= 1.12.2
-- Brings in lots of ekmett dependencies:
-- , either

Expand Down
9 changes: 5 additions & 4 deletions gibbon-compiler/src/Gibbon/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ where

import Control.DeepSeq (NFData(..), force)
import Control.Exception (evaluate)




#if !MIN_VERSION_base(4,13,0)
-- https://downloads.haskell.org/ghc/8.8.1/docs/html/users_guide/8.8.1-notes.html
import Control.Monad.Fail(MonadFail(..))
#endif
import Control.Monad
import Control.Monad.State.Strict
import Control.Monad.Reader
import Data.Functor.Foldable
Expand Down
5 changes: 3 additions & 2 deletions gibbon-compiler/src/Gibbon/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ module Gibbon.Compiler

import Control.DeepSeq
import Control.Exception


#if !MIN_VERSION_base(4,15,0)
#endif
import Control.Monad
import Control.Monad.State.Strict
import Control.Monad.Reader (ask)

Expand Down
Loading

0 comments on commit ee482b0

Please sign in to comment.