Skip to content

Commit

Permalink
Upgrade to Stackage LTS Haskell 10.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Mar 2, 2018
1 parent fe176fb commit 7b3b80e
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 60 deletions.
66 changes: 66 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/HLint.hs → lint.hs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
resolver: lts-9.10
resolver: lts-10.7
flags: {}
packages:
- '.'
extra-deps:
- uri-0.1.6.4
## INSERT CODECOV HERE -- DO NOT REMOVE THIS COMMENT. SEE ALSO ISSUE #156. ##
extra-package-dbs: []
ghc-options:
"$locals": -fhide-source-paths
# http://hsyl20.fr/home/posts/2018-01-15-ghc-hiding-source-and-object-paths.html
require-stack-version: ">=1.6.5"
File renamed without changes.
Loading

0 comments on commit 7b3b80e

Please sign in to comment.