Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit 678cd71

Browse files
authored
Add HLint to CI and fix templates (#243)
1 parent 5d9b01d commit 678cd71

File tree

15 files changed

+56
-44
lines changed

15 files changed

+56
-44
lines changed

.github/workflows/haskell.yml

+7
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ jobs:
1111
name: 47deg
1212
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
1313
- run: nix-build
14+
- name: 'Set up HLint'
15+
16+
- name: 'Run HLint'
17+
18+
with:
19+
path: '["core/schema/src/", "core/rpc/src/", "core/optics/src/", "core/lens/src/", "adapter/avro/src/", "adapter/protobuf/src/", "adapter/persistent/src/", "adapter/kafka/src/", "grpc/common/src/", "grpc/client/src/", "grpc/server/src/", "graphql/src/", "servant/server/src/", "instrumentation/prometheus/src/", "instrumentation/tracing/src/" ]'
20+
fail-on: warning

adapter/kafka/src/Mu/Kafka/Consumer.hs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# language FlexibleContexts #-}
22
{-# language TypeFamilies #-}
3-
{-# language TypeOperators #-}
43
{-|
54
Description : Kafka consumers as streams of Mu terms
65

adapter/kafka/src/Mu/Kafka/Internal.hs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# language ScopedTypeVariables #-}
33
{-# language TypeApplications #-}
44
{-# language TypeFamilies #-}
5-
{-# language TypeOperators #-}
65
module Mu.Kafka.Internal where
76

87
import qualified Data.Avro as A

adapter/kafka/src/Mu/Kafka/Producer.hs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# language DeriveGeneric #-}
22
{-# language FlexibleContexts #-}
33
{-# language TypeFamilies #-}
4-
{-# language TypeOperators #-}
54
{-|
65
Description : streams of Mu terms as Kafka producers
76

adapter/protobuf/mu-protobuf.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: mu-protobuf
2-
version: 0.4.0.0
2+
version: 0.4.0.1
33
synopsis:
44
Protocol Buffers serialization and gRPC schema import for Mu microservices
55

core/lens/src/Mu/Schema/Lens.hs

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
{-# language GADTs #-}
77
{-# language InstanceSigs #-}
88
{-# language LambdaCase #-}
9-
{-# language OverloadedLabels #-}
109
{-# language PartialTypeSignatures #-}
1110
{-# language PolyKinds #-}
1211
{-# language QuantifiedConstraints #-}
@@ -312,14 +311,14 @@ type family InterpretList sch (fieldTypes :: [FieldType typeName]) :: [Type] whe
312311

313312
fromFieldValue :: FieldValue sch fieldType -> Interpret sch fieldType
314313
fromFieldValue = \case
315-
FNull -> ()
316-
(FPrimitive val) -> val
317-
(FSchematic term) -> term
314+
FNull -> ()
315+
(FPrimitive val) -> val
316+
(FSchematic term) -> term
318317
(FOption maybeFieldValue) -> fromFieldValue <$> maybeFieldValue
319-
(FList listFieldValues) -> fromFieldValue <$> listFieldValues
320-
(FMap mapFieldValues) -> mapKeysMonotonic fromFieldValue (fromFieldValue <$> mapFieldValues)
321-
(FUnion (Z val)) -> Z (Identity (fromFieldValue val))
322-
(FUnion (S val)) -> S (fromFieldValue (FUnion val))
318+
(FList listFieldValues) -> fromFieldValue <$> listFieldValues
319+
(FMap mapFieldValues) -> mapKeysMonotonic fromFieldValue (fromFieldValue <$> mapFieldValues)
320+
(FUnion (Z val)) -> Z (Identity (fromFieldValue val))
321+
(FUnion (S val)) -> S (fromFieldValue (FUnion val))
323322

324323
class UninterpretField sch a where
325324
type Uninterpret a :: FieldType typeName

default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let
2-
haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/53ed0a9.tar.gz) {};
2+
haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/134b60e.tar.gz) {};
33
nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
44
nixpkgsArgs = haskellNix.nixpkgsArgs;
55
in

graphql/src/Mu/GraphQL/Quasi/LostParser.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import Text.Parser.Token (braces, symbol, whiteSpace)
1313
schemaDefinition :: Parser GQL.SchemaDefinition
1414
schemaDefinition = symbol "schema" *> braces (
1515
GQL.SchemaDefinition
16-
<$> pure Nothing -- ignore [Directive]
17-
<*> many1 rootOperationParser
16+
Nothing -- ignore [Directive]
17+
<$> many1 rootOperationParser
1818
)
1919

2020
rootOperationParser :: Parser GQL.RootOperationTypeDefinition

grpc/client/src/Mu/GRpc/Client/Record.hs

+3-4
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ serviceDefToDecl serviceTyName complete fieldsPrefix tNamer (Service _ methods)
114114
[pure (DerivClause Nothing [ConT ''Generic])]
115115
let buildName = mkName ("build" ++ complete)
116116
s <- SigD buildName <$> [t|GrpcClient -> $(pure (ConT (mkName complete)))|]
117-
c <- Clause <$> pure []
118-
<*> (NormalB <$> [e|buildService @($(pure $ ConT serviceTyName))
119-
@($(pure $ LitT (StrTyLit fieldsPrefix)))|])
120-
<*> pure []
117+
c <- Clause [] <$> (NormalB <$> [e|buildService @ $(conT serviceTyName)
118+
@ $(litT (strTyLit fieldsPrefix))|])
119+
<*> pure []
121120
pure [d, s, FunD buildName [c]]
122121

123122
methodToDecl :: String -> Namer

grpc/common/src/Mu/GRpc/Avro.hs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
{-# language PolyKinds #-}
88
{-# language ScopedTypeVariables #-}
99
{-# language TypeApplications #-}
10-
{-# language TypeOperators #-}
1110
{-# language UndecidableInstances #-}
1211
{-# options_ghc -fno-warn-orphans -fno-warn-simplifiable-class-constraints #-}
1312
{-|

stack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-16.18
1+
resolver: lts-16.20
22
allow-newer: true
33

44
packages:

templates/graphql-server.hsfiles

+12-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extra-source-files: README.md
1616
executable {{name}}
1717
hs-source-dirs: src
1818
main-is: Main.hs
19+
ghc-options: -Wall
1920
default-language: Haskell2010
2021
build-depends:
2122
base >=4.12 && <5
@@ -29,14 +30,19 @@ executable {{name}}
2930

3031

3132
{-# START_FILE stack.yaml #-}
32-
resolver: lts-16.18
33+
resolver: lts-16.20
3334
allow-newer: true
3435
extra-deps:
35-
- mu-schema-0.3.1.0
36-
- mu-rpc-0.3.4.0
36+
- mu-schema-0.3.1.1
37+
- mu-rpc-0.4.0.0
3738
- mu-graphql-0.4.0.0
3839
- git: https://github.com/hasura/graphql-parser-hs.git
3940
commit: f4a093981ca5626982a17c2bfaad047cc0834a81
41+
- primitive-extras-0.8
42+
- primitive-unlifted-0.1.3.0
43+
- stm-hamt-1.2.0.4
44+
- stm-containers-1.1.0.4
45+
- stm-lifted-2.5.0.0
4046

4147
{-# START_FILE Setup.hs #-}
4248
import Distribution.Simple
@@ -64,16 +70,16 @@ type Query {
6470
{-# language ScopedTypeVariables #-}
6571
{-# language TemplateHaskell #-}
6672
{-# language TypeApplications #-}
73+
{-# language TypeFamilies #-}
6774
{-# language TypeOperators #-}
75+
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
6876

6977
module Main where
7078

7179
import Data.Proxy
72-
import qualified Data.Text as T
7380

7481
import Mu.GraphQL.Quasi
7582
import Mu.GraphQL.Server
76-
import Mu.Schema
7783
import Mu.Server
7884

7985
graphql "ServiceDefinition" "schema.graphql"
@@ -87,5 +93,5 @@ main = do
8793

8894
type ServiceMapping = '[]
8995

90-
server :: MonadServer m => ServerT ServiceMapping ServiceDefinition m _
96+
server :: MonadServer m => ServerT ServiceMapping i ServiceDefinition m _
9197
server = resolver ( object @"Query" ( method @"hello" $ error "not implemented" ) )

templates/grpc-server-avro.hsfiles

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ executable {{name}}
1717
hs-source-dirs: src
1818
main-is: Main.hs
1919
other-modules: Schema
20+
ghc-options: -Wall
2021
default-language: Haskell2010
2122
build-depends:
2223
base >=4.12 && <5
@@ -27,15 +28,15 @@ executable {{name}}
2728
, text
2829

2930
{-# START_FILE stack.yaml #-}
30-
resolver: lts-16.18
31+
resolver: lts-16.20
3132
allow-newer: true
3233
extra-deps:
3334
# mu
34-
- mu-schema-0.3.1.0
35+
- mu-schema-0.3.1.1
3536
- mu-rpc-0.4.0.0
3637
- mu-optics-0.3.0.0
37-
- mu-avro-0.4.0.0
38-
- mu-protobuf-0.4.0.0
38+
- mu-avro-0.4.0.1
39+
- mu-protobuf-0.4.0.1
3940
- mu-grpc-server-0.4.0.0
4041
- mu-grpc-common-0.4.0.0
4142
- compendium-client-0.2.0.0
@@ -80,8 +81,8 @@ protocol Service {
8081

8182
module Schema where
8283

83-
import Data.Text as T
84-
import GHC.Generics
84+
-- import Data.Text as T
85+
-- import GHC.Generics
8586

8687
import Mu.Quasi.Avro
8788
import Mu.Schema
@@ -114,5 +115,5 @@ import Schema
114115
main :: IO ()
115116
main = runGRpcApp msgAvro 8080 server
116117

117-
server :: MonadServer m => SingleServerT TheService m _
118+
server :: MonadServer m => SingleServerT i TheService m _
118119
server = singleService ()

templates/grpc-server-protobuf.hsfiles

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ executable {{name}}
1717
hs-source-dirs: src
1818
main-is: Main.hs
1919
other-modules: Schema
20+
ghc-options: -Wall
2021
default-language: Haskell2010
2122
build-depends:
2223
base >=4.12 && <5
@@ -27,15 +28,15 @@ executable {{name}}
2728
, text
2829

2930
{-# START_FILE stack.yaml #-}
30-
resolver: lts-15.8
31+
resolver: lts-16.20
3132
allow-newer: true
3233
extra-deps:
3334
# mu
34-
- mu-schema-0.3.1.0
35+
- mu-schema-0.3.1.1
3536
- mu-rpc-0.4.0.0
3637
- mu-optics-0.3.0.0
37-
- mu-avro-0.4.0.0
38-
- mu-protobuf-0.4.0.0
38+
- mu-avro-0.4.0.1
39+
- mu-protobuf-0.4.0.1
3940
- mu-grpc-server-0.4.0.0
4041
- mu-grpc-common-0.4.0.0
4142
- compendium-client-0.2.0.0
@@ -85,8 +86,8 @@ service Service {
8586

8687
module Schema where
8788

88-
import Data.Text as T
89-
import GHC.Generics
89+
-- import Data.Text as T
90+
-- import GHC.Generics
9091

9192
import Mu.Quasi.GRpc
9293
import Mu.Schema
@@ -119,5 +120,5 @@ import Schema
119120
main :: IO ()
120121
main = runGRpcApp msgProtoBuf 8080 server
121122

122-
server :: MonadServer m => SingleServerT Service m _
123+
server :: MonadServer m => SingleServerT i Service m _
123124
server = singleService ()

test-templates.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
mkdir template-check
44
cd template-check
55

6-
stack new muavro https://raw.githubusercontent.com/higherkindness/mu-haskell/master/templates/grpc-server-avro.hsfiles -p "author-email:[email protected]" -p "author-name:Haskell Curry"
6+
# copy files (cannot use .. in Stack)
7+
cp ../templates/*.hsfiles .
8+
9+
stack new muavro grpc-server-avro.hsfiles -p "author-email:[email protected]" -p "author-name:Haskell Curry"
710
cd muavro
811
stack build
912
cd ..
1013

11-
stack new muprotobuf https://raw.githubusercontent.com/higherkindness/mu-haskell/master/templates/grpc-server-protobuf.hsfiles -p "author-email:[email protected]" -p "author-name:Haskell Curry"
14+
stack new muprotobuf grpc-server-protobuf.hsfiles -p "author-email:[email protected]" -p "author-name:Haskell Curry"
1215
cd muprotobuf
1316
stack build
1417
cd ..
1518

16-
stack new mugraphql https://raw.githubusercontent.com/higherkindness/mu-haskell/master/templates/graphql-server.hsfiles -p "author-email:[email protected]" -p "author-name:Haskell Curry"
19+
stack new mugraphql graphql-server.hsfiles -p "author-email:[email protected]" -p "author-name:Haskell Curry"
1720
cd mugraphql
1821
stack build
1922
cd ..

0 commit comments

Comments
 (0)