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

Commit af88b3b

Browse files
authored
Fix starting templates (#326)
1 parent 39f40c7 commit af88b3b

File tree

5 files changed

+51
-44
lines changed

5 files changed

+51
-44
lines changed

docs/docs/intro-graphql.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ This schema defines **three types: a book, an author, and a query**. All GraphQL
4646
Now let's have a look at the already finished `src/Main.hs` and we'll go bit by bit explaining what is going on:
4747

4848
```haskell
49-
graphql "ServiceDefinition" "schema.graphql"
49+
{-# language TupleSections #-} -- add this at the top of the file
50+
51+
import Data.Text -- add this at the imports section
52+
53+
graphql "ServiceDefinition" "schema.graphql" -- this is already there
5054

55+
-- you should replace the old main with this new code
5156
main :: IO ()
5257
main = do
5358
putStrLn "starting GraphQL server on port 8080"

docs/docs/intro-rpc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ stack new my_project https://raw.githubusercontent.com/higherkindness/mu-haskell
4949

5050
This command creates a new folder called `my_project`, with a few files. The most important from those are the `.proto` file, in which you will define your service; `src/Schema.hs`, which loads the service definition at compile-time; and `src/Main.hs`, which contains the code of the server.
5151

52-
The first step to get your project running is defining the right schema and service. In this case, you can just copy the definition above after the `package` declaration.
52+
The first step to get your project running is defining the right schema and service. In this case, you can just copy the definition above after the `package` declaration in the newly created `.proto` file.
5353

5454
#### Data type definition
5555

@@ -120,7 +120,7 @@ The `MonadServer` portion in the type is mandated by `mu-rpc`; it tells us that
120120
Another possibility is to use the `optics`-based API in `Mu.Schema.Optics`. In that case, you access the value of the fields using `(^.)` followed by the name of the field after `#`, and build messages by using `record` followed by a tuple of the components. The previous example would then be written:
121121

122122
```haskell
123-
{-# language OverloadedLabels #-}
123+
{-# language OverloadedLabels #-} -- add this at the top of the file
124124

125125
sayHello :: (MonadServer m) => HelloRequestMessage' -> m HelloReplyMessage'
126126
sayHello (HelloRequestMessage nm)

templates/graphql-server.hsfiles

+10-12
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,24 @@ executable {{name}}
2121
build-depends:
2222
base >=4.12 && <5
2323
, conduit
24-
, mu-graphql >=0.4.1
25-
, mu-rpc >=0.4.0
24+
, mu-graphql >=0.5.0
25+
, mu-rpc >=0.5.0
2626
, mu-schema >=0.3.1
2727
, text
2828
, wai-extra
2929
, warp
3030

3131

3232
{-# START_FILE stack.yaml #-}
33-
resolver: lts-16.22
33+
resolver: lts-18.18
3434
allow-newer: true
3535
extra-deps:
36-
- mu-schema-0.3.1.1
37-
- mu-rpc-0.4.0.1
38-
- mu-graphql-0.4.1.0
39-
- graphql-0.11.0.0
40-
- primitive-extras-0.8
41-
- primitive-unlifted-0.1.3.0
42-
- stm-hamt-1.2.0.4
43-
- stm-containers-1.1.0.4
44-
- stm-lifted-2.5.0.0
36+
- mu-schema-0.3.1.2
37+
- mu-rpc-0.5.0.1
38+
- mu-graphql-0.5.0.3
39+
- graphql-1.0.1.0
40+
- stm-containers-1.2
41+
- stm-hamt-1.2.0.6
4542

4643
{-# START_FILE Setup.hs #-}
4744
import Distribution.Simple
@@ -79,6 +76,7 @@ import Data.Proxy
7976

8077
import Mu.GraphQL.Quasi
8178
import Mu.GraphQL.Server
79+
import Mu.Schema
8280
import Mu.Server
8381

8482
graphql "ServiceDefinition" "schema.graphql"

templates/grpc-server-avro.hsfiles

+16-14
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,31 @@ executable {{name}}
2222
build-depends:
2323
base >=4.12 && <5
2424
, mu-avro >=0.4.0
25-
, mu-grpc-server >=0.4.0
26-
, mu-rpc >=0.4.0
25+
, mu-grpc-server >=0.5.0
26+
, mu-rpc >=0.5.0
2727
, mu-schema >=0.3.1
2828
, text
2929

3030
{-# START_FILE stack.yaml #-}
31-
resolver: lts-16.22
31+
resolver: lts-18.18
3232
allow-newer: true
3333
extra-deps:
3434
# mu
35-
- mu-schema-0.3.1.1
36-
- mu-rpc-0.4.0.1
35+
- mu-schema-0.3.1.2
36+
- mu-rpc-0.5.0.1
3737
- mu-optics-0.3.0.1
38-
- mu-avro-0.4.0.2
39-
- mu-protobuf-0.4.0.3
40-
- mu-grpc-server-0.4.0.0
38+
- mu-avro-0.4.0.4
39+
- mu-protobuf-0.4.2.0
40+
- mu-grpc-server-0.5.0.0
4141
- mu-grpc-common-0.4.0.0
4242
- compendium-client-0.2.1.1
4343
# dependencies of mu
44-
- http2-client-0.9.0.0
45-
- http2-grpc-types-0.5.0.0
44+
- http2-client-0.10.0.0
45+
- http2-client-grpc-0.8.0.0
4646
- http2-grpc-proto3-wire-0.1.0.0
47+
- http2-grpc-types-0.5.0.0
48+
- proto3-wire-1.2.2
4749
- warp-grpc-0.4.0.1
48-
- proto3-wire-1.2.0
49-
- parameterized-0.5.0.0
5050

5151
{-# START_FILE Setup.hs #-}
5252
import Distribution.Simple
@@ -81,8 +81,8 @@ protocol Service {
8181

8282
module Schema where
8383

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

8787
import Mu.Quasi.Avro
8888
import Mu.Schema
@@ -100,9 +100,11 @@ avdl "TheSchema" "TheService" "." "{{name}}.avdl"
100100
type Message = Term TheSchema (TheSchema :/: "Message")
101101

102102
{-# START_FILE src/Main.hs #-}
103+
{-# language DataKinds #-}
103104
{-# language FlexibleContexts #-}
104105
{-# language PartialTypeSignatures #-}
105106
{-# language OverloadedStrings #-}
107+
{-# language TypeApplications #-}
106108
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
107109

108110
module Main where

templates/grpc-server-protobuf.hsfiles

+17-15
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,32 @@ executable {{name}}
2121
default-language: Haskell2010
2222
build-depends:
2323
base >=4.12 && <5
24-
, mu-grpc-server >=0.4.0
25-
, mu-protobuf >=0.4.0
26-
, mu-rpc >=0.4.0
24+
, mu-grpc-server >=0.5.0
25+
, mu-protobuf >=0.4.2
26+
, mu-rpc >=0.5.0
2727
, mu-schema >=0.3.1
2828
, text
2929

3030
{-# START_FILE stack.yaml #-}
31-
resolver: lts-16.22
31+
resolver: lts-18.18
3232
allow-newer: true
3333
extra-deps:
3434
# mu
35-
- mu-schema-0.3.1.1
36-
- mu-rpc-0.4.0.1
35+
- mu-schema-0.3.1.2
36+
- mu-rpc-0.5.0.1
3737
- mu-optics-0.3.0.1
38-
- mu-avro-0.4.0.2
39-
- mu-protobuf-0.4.0.3
40-
- mu-grpc-server-0.4.0.0
38+
- mu-avro-0.4.0.4
39+
- mu-protobuf-0.4.2.0
40+
- mu-grpc-server-0.5.0.0
4141
- mu-grpc-common-0.4.0.0
4242
- compendium-client-0.2.1.1
4343
# dependencies of mu
44-
- http2-client-0.9.0.0
45-
- http2-grpc-types-0.5.0.0
44+
- http2-client-0.10.0.0
45+
- http2-client-grpc-0.8.0.0
4646
- http2-grpc-proto3-wire-0.1.0.0
47+
- http2-grpc-types-0.5.0.0
48+
- proto3-wire-1.2.2
4749
- warp-grpc-0.4.0.1
48-
- proto3-wire-1.2.0
49-
- parameterized-0.5.0.0
5050

5151
{-# START_FILE Setup.hs #-}
5252
import Distribution.Simple
@@ -86,8 +86,8 @@ service Service {
8686

8787
module Schema where
8888

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

9292
import Mu.Quasi.GRpc
9393
import Mu.Schema
@@ -105,9 +105,11 @@ grpc "TheSchema" id "{{name}}.proto"
105105
type Message = Term TheSchema (TheSchema :/: "Message")
106106

107107
{-# START_FILE src/Main.hs #-}
108+
{-# language DataKinds #-}
108109
{-# language FlexibleContexts #-}
109110
{-# language PartialTypeSignatures #-}
110111
{-# language OverloadedStrings #-}
112+
{-# language TypeApplications #-}
111113
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
112114

113115
module Main where

0 commit comments

Comments
 (0)