Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/Cabal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# modified from https://github.com/jgm/pandoc/blob/master/.github/workflows/ci.yml
name: Cabal

on:
push:
branches:
- '**'
paths-ignore: []
pull_request:
paths-ignore: []

jobs:
linux:

runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
versions:
- ghc: '8.10.7'
cabal: '3.4'
steps:
- uses: actions/checkout@v2

# need to install older cabal/ghc versions from ppa repository

- name: Install recent cabal/ghc
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.versions.ghc }}
cabal-version: ${{ matrix.versions.cabal }}

# declare/restore cached things
# caching doesn't work for scheduled runs yet
# https://github.com/actions/cache/issues/63

- name: Cache cabal global package db
id: cabal-global
uses: actions/cache@v2
with:
path: |
~/.cabal
key: ${{ runner.os }}-${{ matrix.versions.ghc }}-${{ matrix.versions.cabal }}-cabal-global-${{ hashFiles('cabal.project') }}

- name: Cache cabal work
id: cabal-local
uses: actions/cache@v2
with:
path: |
dist-newstyle
key: ${{ runner.os }}-${{ matrix.versions.ghc }}-${{ matrix.versions.cabal }}-cabal-local

- name: Install dependencies
run: |
cabal update
cabal build all --dependencies-only --enable-tests --disable-optimization
- name: Build
run: |
cabal build all --enable-tests --disable-optimization 2>&1 | tee build.log
# - name: Test # needs GHCJS
# run: |
# cabal test all --disable-optimization
27 changes: 27 additions & 0 deletions .github/workflows/Nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Nix

on:
push:
branches:
- '**'
paths-ignore: []
pull_request:
paths-ignore: []

jobs:
linux:

runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2

# https://github.com/marketplace/actions/install-nix
- name: Install Nix
uses: cachix/install-nix-action@v14
with:
extra_nix_config: |
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://hydra.iohk.io https://cache.nixos.org/
- run: nix-build
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ CodeWorld
=========

[![Build Status](https://travis-ci.org/google/codeworld.svg?branch=master)](https://travis-ci.org/google/codeworld)
[![Build status](https://github.com/google/codeworld/actions/workflows/Cabal.yml/badge.svg)](https://github.com/google/codeworld/actions/workflows/Cabal.yml)
[![Build status](https://github.com/google/codeworld/actions/workflows/Nix.yml/badge.svg)](https://github.com/google/codeworld/actions/workflows/Nix.yml)

CodeWorld is an educational environment using Haskell. It provides a simple
mathematical model for geometric figures, animations, and interactive and
Expand Down
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ packages:
codeworld-server/
codeworld-base/
funblocks-client/

constraints:
ghcjs-dom ==0.9.*
8 changes: 4 additions & 4 deletions codeworld-api/codeworld-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Library
mtl >= 2.2.1 && < 2.3,
random >= 1.1 && < 1.2,
ref-tf >= 0.4 && < 0.5,
reflex >= 0.6.3 && < 0.7,
reflex >= 0.6.3,
template-haskell >= 2.8 && < 2.18,
text >= 1.2.2 && < 1.3,
time >= 1.8 && < 2.0,
Expand All @@ -73,7 +73,7 @@ Library
ghcjs-prim,
codeworld-game-api,
codeworld-prediction,
ghcjs-dom >= 0.9 && < 0.9.4,
ghcjs-dom >= 0.9,
transformers
else
Build-depends: blank-canvas >= 0.6 && < 0.8,
Expand Down Expand Up @@ -122,7 +122,7 @@ Test-suite unit-tests
mtl >= 2.2.1 && < 2.3,
random >= 1.1 && < 1.2,
ref-tf >= 0.4 && < 0.5,
reflex >= 0.6.3 && < 0.7,
reflex >= 0.6.3,
template-haskell >= 2.8 && < 2.18,
text >= 1.2.2 && < 1.3,
time >= 1.8 && < 2.0,
Expand All @@ -134,7 +134,7 @@ Test-suite unit-tests
ghcjs-prim,
codeworld-game-api,
codeworld-prediction,
ghcjs-dom >= 0.9 && < 0.9.4,
ghcjs-dom >= 0.9,
transformers
else
Build-depends: blank-canvas >= 0.6 && < 0.8,
Expand Down
2 changes: 1 addition & 1 deletion codeworld-base/src/Parameter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import qualified CodeWorld.Parameter as CW
import Internal.Picture
import Internal.Text
import Prelude
import "base" Prelude ((.), map)
import "base" Prelude (map, (.))

-- | A drawing that depends on parameters. The first argument is a
-- list of parameters. The second is a picture, which depends on the
Expand Down
8 changes: 5 additions & 3 deletions codeworld-compiler/codeworld-compiler.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ Library
directory,
exceptions,
filepath,
ghc == 8.6.5,
ghc-boot-th == 8.6.5,
ghc == 8.10.*,
ghc-boot,
ghc-boot-th == 8.10.*,
ghc-lib-parser,
hashable,
haskell-src-exts >= 1.20,
megaparsec >= 7.0.0 && < 8.0.0,
memory,
mtl,
process,
regex-base,
regex-tdfa,
regex-tdfa-text,
split,
syb,
temporary,
Expand Down
93 changes: 81 additions & 12 deletions codeworld-compiler/src/CodeWorld/Compile/Framework.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,22 @@ import qualified "ghc" FastString as GHC
import qualified "ghc" Fingerprint as GHC
import qualified "ghc-boot-th" GHC.LanguageExtensions.Type as GHC
import qualified "ghc" HeaderInfo as GHC
import qualified "ghc" HsExtension as GHC
import qualified "ghc" HsSyn as GHC
import qualified "ghc" GHC.Hs.Extension as GHC
import qualified "ghc" GHC.Hs as GHC
import qualified "ghc" RdrHsSyn as GHC
import qualified "ghc" TcHsSyn as GHC
import qualified "ghc" HscTypes as GHC
import Language.Haskell.Exts
import qualified "ghc" Lexer as GHC
import qualified "ghc" Fingerprint as GHC
import qualified "ghc" Module as GHC
import qualified "ghc" Outputable as GHC
import qualified "ghc" Panic as GHC
import qualified "ghc" Parser as GHC
import qualified "ghc" Platform as GHC
import qualified "ghc" GhcNameVersion as GHC
import qualified "ghc" FileSettings as GHC
import qualified "ghc" ToolSettings as GHC
import qualified "ghc-boot" GHC.Platform as GHC
import qualified "ghc" SrcLoc as GHC
import qualified "ghc" StringBuffer as GHC
import System.Directory
Expand Down Expand Up @@ -305,32 +311,95 @@ ghcParseCode extraExts src = do
state = GHC.mkPState dflagsWithPragmas buffer location
return $ case GHC.unP GHC.parseModule state of
GHC.POk _ (GHC.L _ mod) -> GHCParsed mod
GHC.PFailed _ _ _ -> GHCNoParse
GHC.PFailed _ -> GHCNoParse

fakeDynFlags :: GHC.DynFlags
fakeDynFlags = GHC.defaultDynFlags fakeSettings fakeLlvmConfig

fakePlatformMisc :: GHC.PlatformMisc
fakePlatformMisc = GHC.PlatformMisc
mempty
mempty
GHC.IntegerSimple
False
False
False
mempty
False
False
False
False
False
False
mempty

fakeToolSettings :: GHC.ToolSettings
fakeToolSettings = GHC.ToolSettings
True
True
True
True
True
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
(GHC.Fingerprint (read mempty) (read mempty))
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty
mempty

fakeSettings :: GHC.Settings
fakeSettings =
GHC.Settings
{ GHC.sProgramName = "ghcjs",
GHC.sProjectVersion = GHC.cProjectVersion,
{ GHC.sGhcNameVersion = GHC.GhcNameVersion "foo" "foo",
GHC.sFileSettings = GHC.FileSettings mempty mempty Nothing mempty mempty mempty,
GHC.sToolSettings = fakeToolSettings,
GHC.sTargetPlatform =
GHC.Platform
{ GHC.platformWordSize = 8,
GHC.platformOS = GHC.OSUnknown,
GHC.platformUnregisterised = True
{ GHC.platformWordSize = GHC.PW8,
GHC.platformMini = GHC.PlatformMini GHC.ArchX86_64 GHC.OSUnknown,
GHC.platformUnregisterised = True,
GHC.platformHasGnuNonexecStack = True,
GHC.platformIsCrossCompiling = True,
GHC.platformHasSubsectionsViaSymbols = True
},
GHC.sPlatformConstants =
GHC.PlatformConstants
{ GHC.pc_DYNAMIC_BY_DEFAULT = False,
GHC.pc_WORD_SIZE = 8
},
GHC.sOpt_P_fingerprint = GHC.fingerprint0
GHC.sPlatformMisc = fakePlatformMisc
}

fakeLlvmConfig :: (GHC.LlvmTargets, GHC.LlvmPasses)
fakeLlvmConfig = ([], [])
fakeLlvmConfig :: GHC.LlvmConfig
fakeLlvmConfig = GHC.LlvmConfig mempty mempty

parsePragmasIntoDynFlags ::
GHC.DynFlags ->
Expand Down
27 changes: 24 additions & 3 deletions codeworld-compiler/src/CodeWorld/Compile/Requirements/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,27 @@ import Data.Hashable
import Data.List
import qualified Data.Text as T
import Data.Void
import "ghc" HsSyn
import "ghc" GHC.Hs
( GRHS (..),
GRHSs (..),
GhcPs,
GhciLStmt,
HsBind,
HsBindLR (..),
HsExpr (HsApp, HsLet, HsPar, HsVar),
HsModule (..),
ImportDecl,
LHsDecl,
LHsExpr,
LMatch,
Match (..),
MatchGroup (..),
Sig (TypeSig),
pprFunBind,
pprPatBind,
)
import "ghc" GHC.Hs.Decls
import "ghc" GHC.Hs.Pat
import qualified Language.Haskell.Exts as Exts
import "ghc" Outputable
import "ghc" SrcLoc
Expand Down Expand Up @@ -192,8 +212,9 @@ checkRule (AllOf rules) = do
return (concat <$> results)
checkRule (AnyOf rules) = do
results <- sequence <$> mapM checkRule rules
return $ (<$> results) $ \errs ->
if any null errs then [] else ["No alternatives succeeded."]
return $
(<$> results) $ \errs ->
if any null errs then [] else ["No alternatives succeeded."]
checkRule (NotThis rule) = do
result <- checkRule rule
case result of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import Data.Generics
import Data.Generics.Twins
import Data.List
import Data.Maybe
import "ghc" HsSyn
import "ghc" RdrHsSyn
import "ghc" GHC.Hs
import "ghc" OccName
import "ghc" RdrName
import "ghc" SrcLoc
Expand Down
2 changes: 1 addition & 1 deletion codeworld-compiler/src/CodeWorld/Compile/Stages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import Data.Monoid
import Data.Text (Text, unpack)
import Data.Text.Encoding (decodeUtf8)
import qualified "ghc" FastString as GHC
import qualified "ghc" HsSyn as GHC
import qualified "ghc" GHC.Hs as GHC
import Language.Haskell.Exts
import qualified "ghc" Module as GHC
import qualified "ghc" OccName as GHC
Expand Down
6 changes: 2 additions & 4 deletions codeworld-error-sanitizer/codeworld-error-sanitizer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Library
else
Build-depends: array,
regex-base,
regex-tdfa,
regex-tdfa-text
regex-tdfa

Default-language: Haskell2010
Exposed: True
Expand All @@ -49,7 +48,6 @@ Test-suite unit-tests
else
Build-depends: array,
regex-base,
regex-tdfa,
regex-tdfa-text
regex-tdfa

Default-language: Haskell2010
2 changes: 1 addition & 1 deletion codeworld-requirements/codeworld-requirements.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ library
haskell-src-exts >= 1.20,
mtl,
process,
regex-base,
regex-tdfa,
regex-tdfa-text,
syb,
temporary,
text,
Expand Down
Loading