2019-12-03 16:45:21 +03:00
|
|
|
|
{-# START_FILE {{name}}.cabal #-}
|
2020-04-17 14:01:25 +03:00
|
|
|
|
name: {{name}}
|
|
|
|
|
version: 0.1.0.0
|
|
|
|
|
|
2019-12-03 16:45:21 +03:00
|
|
|
|
-- synopsis:
|
|
|
|
|
-- description:
|
2020-04-17 14:01:25 +03:00
|
|
|
|
homepage: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{name}}#readme
|
|
|
|
|
author: {{author-name}}{{^author-name}}Author name here{{/author-name}}
|
|
|
|
|
maintainer: {{author-email}}{{^author-email}}example@example.com{{/author-email}}
|
|
|
|
|
copyright: {{copyright}}{{^copyright}}{{year}}{{^year}}2020{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}{{/copyright}}
|
|
|
|
|
category: {{category}}{{^category}}Web{{/category}}
|
|
|
|
|
build-type: Simple
|
|
|
|
|
cabal-version: >=1.10
|
|
|
|
|
extra-source-files: README.md
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
|
|
|
|
executable {{name}}
|
2020-04-17 14:01:25 +03:00
|
|
|
|
hs-source-dirs: src
|
|
|
|
|
main-is: Main.hs
|
|
|
|
|
other-modules: Schema
|
2020-11-02 11:42:35 +03:00
|
|
|
|
ghc-options: -Wall
|
2020-04-17 14:01:25 +03:00
|
|
|
|
default-language: Haskell2010
|
|
|
|
|
build-depends:
|
|
|
|
|
base >=4.12 && <5
|
2020-10-12 15:56:18 +03:00
|
|
|
|
, mu-avro >=0.4.0
|
|
|
|
|
, mu-grpc-server >=0.4.0
|
|
|
|
|
, mu-rpc >=0.4.0
|
|
|
|
|
, mu-schema >=0.3.1
|
2020-04-17 14:01:25 +03:00
|
|
|
|
, text
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
|
|
|
|
{-# START_FILE stack.yaml #-}
|
2020-11-19 11:04:24 +03:00
|
|
|
|
resolver: lts-16.22
|
2020-01-13 14:40:28 +03:00
|
|
|
|
allow-newer: true
|
2019-12-03 16:45:21 +03:00
|
|
|
|
extra-deps:
|
|
|
|
|
# mu
|
2020-11-02 11:42:35 +03:00
|
|
|
|
- mu-schema-0.3.1.1
|
2020-11-19 11:04:24 +03:00
|
|
|
|
- mu-rpc-0.4.0.1
|
|
|
|
|
- mu-optics-0.3.0.1
|
2020-11-19 11:47:14 +03:00
|
|
|
|
- mu-avro-0.4.0.2
|
2020-11-23 11:24:10 +03:00
|
|
|
|
- mu-protobuf-0.4.0.3
|
2020-10-12 15:56:18 +03:00
|
|
|
|
- mu-grpc-server-0.4.0.0
|
|
|
|
|
- mu-grpc-common-0.4.0.0
|
2020-11-19 11:04:24 +03:00
|
|
|
|
- compendium-client-0.2.1.1
|
2019-12-03 16:45:21 +03:00
|
|
|
|
# dependencies of mu
|
|
|
|
|
- http2-client-0.9.0.0
|
|
|
|
|
- http2-grpc-types-0.5.0.0
|
|
|
|
|
- http2-grpc-proto3-wire-0.1.0.0
|
2020-04-20 16:48:29 +03:00
|
|
|
|
- warp-grpc-0.4.0.1
|
2020-10-12 15:56:18 +03:00
|
|
|
|
- proto3-wire-1.2.0
|
|
|
|
|
- parameterized-0.5.0.0
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
|
|
|
|
{-# START_FILE Setup.hs #-}
|
|
|
|
|
import Distribution.Simple
|
|
|
|
|
main = defaultMain
|
|
|
|
|
|
|
|
|
|
{-# START_FILE .gitignore #-}
|
|
|
|
|
.stack-work/
|
|
|
|
|
stack*.yaml.lock
|
|
|
|
|
*~
|
|
|
|
|
|
|
|
|
|
{-# START_FILE README.md #-}
|
|
|
|
|
# {{name}}
|
|
|
|
|
|
2020-02-14 13:12:21 +03:00
|
|
|
|
{-# START_FILE {{name}}.avdl #-}
|
2020-02-06 13:39:09 +03:00
|
|
|
|
@namespace("{{name}}")
|
|
|
|
|
protocol Service {
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{-# START_FILE src/Schema.hs #-}
|
|
|
|
|
{-# language DataKinds #-}
|
|
|
|
|
{-# language DeriveAnyClass #-}
|
|
|
|
|
{-# language DeriveGeneric #-}
|
|
|
|
|
{-# language DuplicateRecordFields #-}
|
|
|
|
|
{-# language FlexibleContexts #-}
|
|
|
|
|
{-# language FlexibleInstances #-}
|
|
|
|
|
{-# language MultiParamTypeClasses #-}
|
|
|
|
|
{-# language PolyKinds #-}
|
|
|
|
|
{-# language TemplateHaskell #-}
|
2019-12-04 14:35:05 +03:00
|
|
|
|
{-# language TypeFamilies #-}
|
2019-12-03 16:45:21 +03:00
|
|
|
|
{-# language TypeOperators #-}
|
2020-02-27 09:40:30 +03:00
|
|
|
|
|
2019-12-03 16:45:21 +03:00
|
|
|
|
module Schema where
|
|
|
|
|
|
2020-11-02 11:42:35 +03:00
|
|
|
|
-- import Data.Text as T
|
|
|
|
|
-- import GHC.Generics
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
2020-02-06 13:39:09 +03:00
|
|
|
|
import Mu.Quasi.Avro
|
2019-12-04 10:31:11 +03:00
|
|
|
|
import Mu.Schema
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
2020-02-06 13:39:09 +03:00
|
|
|
|
avdl "TheSchema" "TheService" "." "{{name}}.avdl"
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
2020-02-04 17:31:47 +03:00
|
|
|
|
-- A. Map to Haskell types
|
2019-12-03 16:45:21 +03:00
|
|
|
|
-- data Message
|
|
|
|
|
-- = Message { ... }
|
2019-12-16 15:46:43 +03:00
|
|
|
|
-- deriving ( Eq, Show, Generic
|
2020-04-17 14:01:25 +03:00
|
|
|
|
-- , ToSchema TheSchema "Message"
|
|
|
|
|
-- , FromSchema TheSchema "Message" )
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
2020-02-04 17:31:47 +03:00
|
|
|
|
-- B. Use optics
|
2020-04-17 14:01:25 +03:00
|
|
|
|
type Message = Term TheSchema (TheSchema :/: "Message")
|
2020-02-04 17:31:47 +03:00
|
|
|
|
|
2019-12-03 16:45:21 +03:00
|
|
|
|
{-# START_FILE src/Main.hs #-}
|
2020-01-13 14:40:28 +03:00
|
|
|
|
{-# language FlexibleContexts #-}
|
2019-12-03 16:45:21 +03:00
|
|
|
|
{-# language PartialTypeSignatures #-}
|
2020-01-14 10:44:07 +03:00
|
|
|
|
{-# language OverloadedStrings #-}
|
2019-12-16 15:46:43 +03:00
|
|
|
|
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
|
2020-02-27 09:40:30 +03:00
|
|
|
|
|
2019-12-03 16:45:21 +03:00
|
|
|
|
module Main where
|
|
|
|
|
|
|
|
|
|
import Mu.GRpc.Server
|
|
|
|
|
import Mu.Server
|
|
|
|
|
|
|
|
|
|
import Schema
|
|
|
|
|
|
|
|
|
|
main :: IO ()
|
2020-03-17 15:24:48 +03:00
|
|
|
|
main = runGRpcApp msgAvro 8080 server
|
2019-12-03 16:45:21 +03:00
|
|
|
|
|
2020-11-02 11:42:35 +03:00
|
|
|
|
server :: MonadServer m => SingleServerT i TheService m _
|
2020-04-17 14:01:25 +03:00
|
|
|
|
server = singleService ()
|