30
common/LICENSE
Normal file
30
common/LICENSE
Normal file
@ -0,0 +1,30 @@
|
||||
Copyright (c) 2018, Mats Rauhala
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Mats Rauhala nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
65
common/common.cabal
Normal file
65
common/common.cabal
Normal file
@ -0,0 +1,65 @@
|
||||
name: common
|
||||
version: 0.1.0.0
|
||||
-- synopsis:
|
||||
-- description:
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Mats Rauhala
|
||||
maintainer: mats.rauhala@iki.fi
|
||||
-- copyright:
|
||||
category: Web
|
||||
build-type: Simple
|
||||
extra-source-files: ChangeLog.md
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
exposed-modules: Configuration
|
||||
, Data.Versioned
|
||||
-- other-extensions:
|
||||
build-depends: base >=4.10 && <4.11
|
||||
, aeson
|
||||
, asn1-data
|
||||
, asn1-types
|
||||
, bytestring
|
||||
, classy-prelude
|
||||
, cryptonite
|
||||
, dhall
|
||||
, directory
|
||||
, foreign-store
|
||||
, generic-lens
|
||||
, http-api-data
|
||||
, http-media
|
||||
, jose
|
||||
, lens
|
||||
, lucid
|
||||
, memory
|
||||
, monad-logger
|
||||
, mtl
|
||||
, pandoc
|
||||
, pandoc-types
|
||||
, pem
|
||||
, process
|
||||
, resource-pool
|
||||
, selda
|
||||
, selda-postgresql
|
||||
, servant
|
||||
, servant-auth
|
||||
, servant-auth-server
|
||||
, servant-docs
|
||||
, servant-lucid
|
||||
, servant-multipart
|
||||
, servant-server
|
||||
, text
|
||||
, transformers
|
||||
, wai
|
||||
, warp
|
||||
, x509
|
||||
, x509-store
|
||||
, xml-conduit
|
||||
, xml-hamlet
|
||||
hs-source-dirs: src
|
||||
default-extensions: DeriveGeneric
|
||||
, NoImplicitPrelude
|
||||
, OverloadedStrings
|
||||
, RecordWildCards
|
||||
default-language: Haskell2010
|
23
common/src/Configuration.hs
Normal file
23
common/src/Configuration.hs
Normal file
@ -0,0 +1,23 @@
|
||||
{-# Language NoImplicitPrelude #-}
|
||||
{-# Language DeriveGeneric #-}
|
||||
{-# Language DuplicateRecordFields #-}
|
||||
module Configuration where
|
||||
|
||||
import ClassyPrelude
|
||||
import Dhall (Interpret)
|
||||
|
||||
data Pg = Pg { username :: Text
|
||||
, password :: Text
|
||||
, host :: Text
|
||||
, database :: Text }
|
||||
deriving (Show, Generic)
|
||||
|
||||
newtype Store = Store { path :: Text } deriving (Show, Generic)
|
||||
|
||||
data Config = Config { database :: Pg
|
||||
, store :: Store }
|
||||
deriving (Show, Generic)
|
||||
|
||||
instance Interpret Pg
|
||||
instance Interpret Store
|
||||
instance Interpret Config
|
24
common/src/Data/Versioned.hs
Normal file
24
common/src/Data/Versioned.hs
Normal file
@ -0,0 +1,24 @@
|
||||
{-# Language KindSignatures #-}
|
||||
{-# Language DataKinds #-}
|
||||
{-# Language DefaultSignatures #-}
|
||||
{-# Language MultiParamTypeClasses #-}
|
||||
{-# Language FunctionalDependencies #-}
|
||||
module Data.Versioned where
|
||||
|
||||
import GHC.TypeLits
|
||||
import ClassyPrelude
|
||||
import Data.Generics.Product
|
||||
|
||||
newtype Versioned (v :: Nat) a = Versioned a deriving (Show)
|
||||
|
||||
instance Functor (Versioned v) where
|
||||
fmap f (Versioned a) = Versioned (f a)
|
||||
|
||||
instance Applicative (Versioned v) where
|
||||
pure = Versioned
|
||||
(Versioned f) <*> (Versioned a) = Versioned (f a)
|
||||
|
||||
class Migrate a b | b -> a where
|
||||
migrate :: a -> b
|
||||
default migrate :: (Subtype b a) => a -> b
|
||||
migrate = upcast
|
Reference in New Issue
Block a user