Skip to content

Commit

Permalink
Upgrade to Stackage LTS Haskell 10.7 (#240)
Browse files Browse the repository at this point in the history
* Upgrade to Stackage LTS Haskell 10.7

* Fix broken build on Windows

> Error: While constructing the build plan, the following exceptions were encountered:
> In the dependencies for turtle-1.4.5:
>     Win32-2.5.4.1 from stack configuration does not match >=2.2.0.1 && <2.4 (latest matching version
>                   is 2.3.1.1)
> needed due to nirum-0.3.0 -> turtle-1.4.5
> Some potential ways to resolve this:
>   * Recommended action: try adding the following to your extra-deps
>     in C:\projects\nirum-k5n5y\stack.yaml:
> - Win32-2.3.1.1
>   * Set 'allow-newer: true' to ignore all version constraints and build anyway.
>   * You may also want to try using the 'stack solver' command.
> Plan construction failed.

[changelog skip]
  • Loading branch information
dahlia committed Mar 3, 2018
1 parent fe176fb commit d80195a
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 63 deletions.
66 changes: 66 additions & 0 deletions .hlint.yaml
@@ -0,0 +1,66 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint
##########################

# This file contains a template configuration file, which is typically
# placed as .hlint.yaml in the root of your project


# Specify additional command line arguments
#
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]


# Control which extensions/flags/modules/functions can be used
#
# - extensions:
# - default: false # all extension are banned by default
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
#
# - flags:
# - {name: -w, within: []} # -w is allowed nowhere
#
# - modules:
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
#
# - functions:
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules


# Add custom hints for this project
#
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}


# Turn on hints that are off by default
#
# Ban "module X(module X) where", to require a real export list
# - warn: {name: Use explicit module export list}
#
# Replace a $ b $ c with a . b $ c
# - group: {name: dollar, enabled: true}
#
# Generalise map to fmap, ++ to <>
# - group: {name: generalise, enabled: true}


# Ignore some builtin hints
# - ignore: {name: Use let}
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
- ignore:
name: Reduce duplication
within:
- Nirum.Parser
- Nirum.ParserSpec
- ignore: {name: Unnecessary hiding}


# Define some custom infix operators
# - fixity: infixr 3 ~^#^~


# To generate a suitable file for HLint do:
# $ hlint --default > .hlint.yaml
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -118,7 +118,8 @@ install:
fi
script:
- 'TOX="$(which tox)" stack --no-terminal test -j4 --coverage'
- ls -al "$(python3 -m site --user-base)/bin/tox"
- 'TOX="$(python3 -m site --user-base)/bin/tox" stack --no-terminal test -j4 --coverage'
- ./lint.sh

after_script:
Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Expand Up @@ -22,10 +22,10 @@ install:
- ps: >
if((Test-Path $env:STACK_ROOT) -ne $true) {
if($env:PLATFORM -eq 'x86') {
$stackUrl = 'https://www.stackage.org/stack/windows-i386';
$stackUrl = 'https://github.com/commercialhaskell/stack/releases/download/v1.6.5/stack-1.6.5-windows-i386.zip';
}
elseif($env:PLATFORM -eq 'x64') {
$stackUrl = 'https://www.stackage.org/stack/windows-x86_64';
$stackUrl = 'https://github.com/commercialhaskell/stack/releases/download/v1.6.5/stack-1.6.5-windows-x86_64.zip';
}
Invoke-WebRequest -OutFile C:\stack.zip $stackUrl;
Add-Type -AssemblyName System.IO.Compression.FileSystem;
Expand All @@ -49,6 +49,7 @@ install:
- set

- C:\Python36\python -m pip install --upgrade tox pip setuptools
- stack --no-terminal install -j4 happy # haskell-src-exts requires happy
- stack --no-terminal install -j4 --only-dependencies
build_script:
- stack --no-terminal build -j4 --copy-bins --flag nirum:static
Expand Down
2 changes: 1 addition & 1 deletion test/HLint.hs → lint.hs
Expand Up @@ -2,7 +2,7 @@ import Language.Haskell.HLint (hlint)
import System.Exit (exitFailure, exitSuccess)

arguments :: [String]
arguments = ["src", "test"]
arguments = ["app", "src", "test", "lint.hs"]

main :: IO ()
main = do
Expand Down
32 changes: 23 additions & 9 deletions package.yaml
Expand Up @@ -33,9 +33,16 @@ flags:
description: Static link
manual: true
default: false
ghc-options:
- -Wall
- -Werror
when:
- condition: os(darwin)
else:
ghc-options:
- -Werror
then:
ghc-options:
- -Werror
- -optP-Wno-nonportable-include-path
# The above option works around https://github.com/haskell/cabal/issues/4739
dependencies:
- base >=4.7 && <5
- blaze-html >=0.9.0.1 && <0.10
Expand All @@ -46,7 +53,7 @@ dependencies:
- filepath >=1.4 && <1.5
- htoml >=1.0.0.0 && <1.1.0.0
- interpolatedstring-perl6 >=1.0.0 && <1.1.0
- megaparsec >=5 && <5.4
- megaparsec >=6.3 && <6.4
- mtl >=2.2.1 && <3
- parsec # only for dealing with htoml's ParserError
- pretty >=1.1.3 && <2
Expand All @@ -56,6 +63,7 @@ dependencies:
library:
source-dirs: src
ghc-options:
- -Wall
- -fwarn-incomplete-uni-patterns
- -fprint-explicit-kinds
other-modules:
Expand All @@ -65,7 +73,7 @@ library:
- cmark >=0.5 && <0.6
- fsnotify >=0.2.1 && <0.3.0
- heterocephalus >=1.0.5 && <1.1.0
- optparse-applicative >=0.13.1 && <0.14
- optparse-applicative >=0.14 && <0.15
- shakespeare >=2.0.12 && <2.1
- stm >=2.4.4.1
- template-haskell >=2.11 && <3
Expand All @@ -75,6 +83,7 @@ executables:
main: nirum.hs
source-dirs: app
dependencies:
- base
- nirum
when:
- condition: flag(static)
Expand All @@ -83,6 +92,7 @@ executables:
- condition: os(darwin) || os(windows)
then:
ghc-options:
- -Wall
- -fwarn-incomplete-uni-patterns
- -threaded
- -with-rtsopts=-N
Expand All @@ -91,6 +101,7 @@ executables:
- -optc-Os
else:
ghc-options:
- -Wall
- -fwarn-incomplete-uni-patterns
- -threaded
- -with-rtsopts=-N
Expand All @@ -102,21 +113,24 @@ executables:
- -fPIC
else:
ghc-options:
- -Wall
- -fwarn-incomplete-uni-patterns
- -threaded
- -with-rtsopts=-N
tests:
hlint:
main: HLint.hs
source-dirs: test
main: lint.hs
dependencies:
- hlint >=2.0.9 && <2.1
spec:
main: Spec.hs
source-dirs: test
main: Main.hs
source-dirs:
- test
ghc-options:
- -Wall
- -fno-warn-incomplete-uni-patterns
- -fno-warn-missing-signatures
- -Wno-missing-signatures
- -threaded
- -with-rtsopts=-N
dependencies: # omit version specifiers for shared dependencies to library
Expand Down
11 changes: 3 additions & 8 deletions src/Nirum/Cli.hs
Expand Up @@ -18,11 +18,7 @@ import System.Exit (die)
import System.FilePath (takeDirectory, takeExtension, (</>))
import System.FSNotify
import Text.InterpolatedString.Perl6 (qq)
import Text.Megaparsec (Token)
import Text.Megaparsec.Error ( Dec
, ParseError (errorPos)
, parseErrorPretty
)
import Text.Megaparsec.Error (errorPos, parseErrorPretty)
import Text.Megaparsec.Pos (SourcePos (sourceLine, sourceColumn), unPos)

import Nirum.Constructs (Construct (toCode))
Expand All @@ -33,6 +29,7 @@ import Nirum.Package ( PackageError ( ImportError
, ParseError
, ScanError
)
, ParseError
, scanModules
)
import Nirum.Package.ModuleSet ( ImportError ( CircularImportError
Expand Down Expand Up @@ -67,9 +64,7 @@ data AppOptions = AppOptions { outputPath :: FilePath
debounceDelay :: Nanosecond
debounceDelay = 1 * 1000 * 1000

parseErrortoPrettyMessage :: ParseError (Token T.Text) Dec
-> FilePath
-> IO String
parseErrortoPrettyMessage :: ParseError -> FilePath -> IO String
parseErrortoPrettyMessage parseError' filePath' = do
sourceCode <- readFile filePath'
let sourceLines = lines sourceCode
Expand Down
6 changes: 3 additions & 3 deletions src/Nirum/Constructs/Identifier.hs
Expand Up @@ -22,12 +22,12 @@ module Nirum.Constructs.Identifier ( Identifier
import Data.Char (toLower, toUpper)
import Data.Maybe (fromMaybe)
import Data.String (IsString (fromString))
import Data.Void

import qualified Data.Text as T
import qualified Data.Set as S
import qualified Text.Megaparsec as P
import Text.Megaparsec.Char (oneOf, satisfy)
import Text.Megaparsec.Text (Parser)

import Nirum.Constructs (Construct (toCode))

Expand Down Expand Up @@ -64,7 +64,7 @@ reservedKeywords = [ "enum"
, "default"
]

identifierRule :: Parser Identifier
identifierRule :: P.Parsec Void T.Text Identifier
identifierRule = do
firstChar <- satisfy isAlpha
restChars <- P.many $ satisfy isAlnum
Expand All @@ -89,7 +89,7 @@ fromText text =
Right ident -> Just ident
Left _ -> Nothing
where
rule :: Parser Identifier
rule :: P.Parsec Void T.Text Identifier
rule = do
identifier' <- identifierRule
_ <- P.eof
Expand Down
1 change: 1 addition & 0 deletions src/Nirum/Package.hs
@@ -1,6 +1,7 @@
module Nirum.Package
( Package (..)
, PackageError (..)
, ParseError
, docs
, resolveModule
, scanModules
Expand Down
28 changes: 13 additions & 15 deletions src/Nirum/Package/Metadata.hs
@@ -1,4 +1,4 @@
{-# LANGUAGE GADTs, QuasiQuotes, RankNTypes, ScopedTypeVariables,
{-# LANGUAGE GADTs, LambdaCase, QuasiQuotes, RankNTypes, ScopedTypeVariables,
StandaloneDeriving, TypeFamilies #-}
module Nirum.Package.Metadata ( Author (Author, email, name, uri)
, Metadata ( Metadata
Expand Down Expand Up @@ -261,14 +261,14 @@ optional (Left (FieldError _)) = Right Nothing
optional (Left error') = Left error'

tableField :: MetadataField -> Table -> Either MetadataError Table
tableField = typedField "table" $ \ n -> case n of
VTable t -> Just t
_ -> Nothing
tableField = typedField "table" $ \ case
VTable t -> Just t
_ -> Nothing

stringField :: MetadataField -> Table -> Either MetadataError Text
stringField = typedField "string" $ \ n -> case n of
VString s -> Just s
_ -> Nothing
stringField = typedField "string" $ \ case
VString s -> Just s
_ -> Nothing

arrayField :: MetadataField -> Table -> Either MetadataError VArray
arrayField f t =
Expand All @@ -278,10 +278,9 @@ arrayField f t =
Left error' -> Left error'
where
arrayF :: MetadataField -> Table -> Either MetadataError VArray
arrayF = typedField "array" $ \ node ->
case node of
VArray array -> Just array
_ -> Nothing
arrayF = typedField "array" $ \ case
VArray array -> Just array
_ -> Nothing


tableArrayField :: MetadataField -> Table -> Either MetadataError VTArray
Expand All @@ -292,10 +291,9 @@ tableArrayField f t =
Left error' -> Left error'
where
arrayF :: MetadataField -> Table -> Either MetadataError VTArray
arrayF = typedField "array of tables" $ \ node ->
case node of
VTArray array -> Just array
_ -> Nothing
arrayF = typedField "array of tables" $ \ case
VTArray array -> Just array
_ -> Nothing

uriField :: MetadataField -> Table -> Either MetadataError URI
uriField field' table = do
Expand Down
13 changes: 6 additions & 7 deletions src/Nirum/Parser.hs
Expand Up @@ -33,11 +33,12 @@ module Nirum.Parser ( Parser
) where

import Control.Monad (void)
import Data.Void
import qualified System.IO as SIO

import qualified Data.List as L
import Data.Map.Strict as Map hiding (foldl)
import Data.Set hiding (empty, foldl, fromList, map)
import Data.Set hiding (foldl)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Text.Megaparsec hiding (ParseError, parse)
Expand All @@ -49,8 +50,7 @@ import Text.Megaparsec.Char ( char
, string'
)
import qualified Text.Megaparsec.Error as E
import Text.Megaparsec.Text (Parser)
import Text.Megaparsec.Lexer (charLiteral)
import Text.Megaparsec.Char.Lexer (charLiteral)

import qualified Nirum.Constructs.Annotation as A
import Nirum.Constructs.Declaration (Declaration)
Expand Down Expand Up @@ -80,7 +80,8 @@ import Nirum.Constructs.TypeExpression ( TypeExpression ( ListModifier
)
)

type ParseError = E.ParseError (Token T.Text) E.Dec
type Parser = Parsec Void T.Text
type ParseError = E.ParseError Char Void

-- CHECK: If a new reserved keyword is introduced, it has to be also
-- added to `reservedKeywords` set in the `Nirum.Constructs.Identifier`
Expand Down Expand Up @@ -494,7 +495,7 @@ typeDeclaration = do
let annotations = A.union annotationSet' $ typeAnnotations typeDecl
return $ typeDecl { typeAnnotations = annotations }
where
unless' :: [String] -> Parser a -> Parser a
unless' :: [T.Text] -> Parser a -> Parser a
unless' [] _ = fail "no candidates" -- Must never happen
unless' [s] p = notFollowedBy (string s) >> p
unless' (x : xs) p = notFollowedBy (string x) >> unless' xs p
Expand Down Expand Up @@ -662,5 +663,3 @@ parseFile path = do
SIO.hSetEncoding h SIO.utf8_bom
TIO.hGetContents h
return $ runParser file path code

{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}
9 changes: 1 addition & 8 deletions src/Nirum/Targets.hs
@@ -1,14 +1,7 @@
{-# LANGUAGE QuasiQuotes, ScopedTypeVariables, TemplateHaskell #-}
module Nirum.Targets ( BuildError (CompileError, PackageError, TargetNameError)
, BuildResult
, Target ( CompileError
, CompileResult
, compilePackage
, parseTarget
, showCompileError
, targetName
, toByteString
)
, Target (..)
, TargetName
, buildPackage
, targetNames
Expand Down

0 comments on commit d80195a

Please sign in to comment.