| title | Passing a DB connection to handlers in Servant |
|---|---|
| author | Oleg |
This write-up is motivated by discussion in servant/#704 issue. I try to summarize the main points.
As this is a literate haskell file, we'll need to do a small prelude dance:
| -- These examples are based on the tutorial module in the io-streams package | |
| {-#LANGUAGE OverloadedStrings #-} | |
| import Streaming | |
| import Streaming.Prelude (yield, next, each, for, with, subst) | |
| import qualified Streaming.Prelude as S | |
| import qualified Data.ByteString.Char8 as B | |
| import Data.ByteString.Streaming (ByteString) | |
| import qualified Data.ByteString.Streaming.Char8 as Q | |
| import System.IO (withFile, IOMode(..)) |
| {-#LANGUAGE OverloadedStrings #-} | |
| import Streaming | |
| import Streaming.Prelude (each, next, yield) | |
| import qualified Data.ByteString.Streaming.Char8 as Q | |
| import qualified Data.ByteString.Char8 as B | |
| import qualified Streaming.Prelude as S | |
| import qualified Control.Foldl as L | |
| import Data.ByteString.Streaming.HTTP -- git clone https://github.com/michaelt/streaming-http | |
| -- cabal install ./streaming-http | |
| infixl 5 >>>; (>>>) = flip (.) |
| #!/usr/bin/env python | |
| # coding=utf8 | |
| """ | |
| Copyright (c) 2015 ServerAstra Ltd. | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| import Control.Monad.IO.Class | |
| import Control.Monad.Trans.Class | |
| import Prelude hiding (log) | |
| -------------------------------------------------------------------------------- | |
| -- The API for cloud files. | |
| class Monad m => MonadCloud m where | |
| saveFile :: Path -> Bytes -> m () |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main (main) where | |
| import Prelude () | |
| import Prelude.Compat | |
| import Control.Concurrent (threadDelay) |
| resource "aws_iam_policy" "terraform_create_policy" { | |
| name = "terraform_create_policy" | |
| path = "/" | |
| policy = "${data.aws_iam_policy_document.terraform_create_policy.json}" | |
| } | |
| data "aws_iam_policy_document" "terraform_create_policy" { | |
| statement { | |
| sid = "1" | |
| actions = [ |
| title | Passing a DB connection to handlers in Servant |
|---|---|
| author | Oleg |
This write-up is motivated by discussion in servant/#704 issue. I try to summarize the main points.
As this is a literate haskell file, we'll need to do a small prelude dance:
| title | Solution to servant API type indentation problem |
|---|---|
| author | Oleg |
This post is a literate Haskell file: so there are few imports, and {-# LANGUAGE TypedKitchenSink #-}.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}| { config, lib, ... }: | |
| with lib; | |
| let | |
| cfg = config.services.nixBinaryCacheCache; | |
| nginxCfg = config.services.nginx; |
| ### WAN backup routing via LTE ### | |
| # A Linux device, such as PC Engines APU, can be equipped with an LTE modem, but | |
| # sometimes it's desirable to use the mobile connection only if the wired | |
| # connection is unavailable. | |
| # The following scenario is for Debian 9 on an APU box, but it's also | |
| # applicable to any other Linux device. | |
| # The DHCP client is tweaked to ignore the DNS server addresses that are |