This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(try_trait_v2)] | |
use std::ops::Try; | |
trait Monoid: Default { | |
fn mappend(self, rhs: Self) -> Self; | |
} | |
impl Monoid for i32 { | |
fn mappend(self, rhs: Self) -> Self { | |
self + rhs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings, QuasiQuotes, TemplateHaskell, TypeFamilies #-} | |
module App where | |
import ClassyPrelude hiding (Handler) | |
import Control.Exception.Safe (throw) | |
import Data.Aeson | |
import Deriving.Aeson | |
import GHC.Generics | |
import Prelude () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(hash_set_entry)] | |
use ouroboros::self_referencing; | |
use crate::append_set::AppendSet; | |
mod append_set { | |
use std::collections::HashSet; | |
use parking_lot::Mutex; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(never_type)] | |
pub enum Conduit<I, O, R> { | |
Send(O, Box<dyn FnOnce() -> Conduit<I, O, R>>), | |
Recv(Box<dyn FnOnce(Option<I>) -> Conduit<I, O, R>>), | |
Done(R), | |
Leftover(I, Box<dyn FnOnce() -> Conduit<I, O, R>>), | |
} | |
use Conduit::*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use hyper::{Client, Server, Request, Response, Body}; | |
use anyhow::*; | |
use std::net::SocketAddr; | |
use hyper::service::{make_service_fn, service_fn}; | |
use std::sync::{Arc, RwLock}; | |
fn mutate_request(req: &mut Request<Body>) -> Result<()> { | |
for key in &["content-length", "transfer-encoding", "accept-encoding", "content-encoding"] { | |
req.headers_mut().remove(*key); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(generic_associated_types)] | |
#[allow(dead_code)] | |
trait Functor { | |
type Unwrapped; | |
type Wrapped<B>: Functor; | |
fn map<F, B>(self, f: F) -> Self::Wrapped<B> | |
where | |
F: FnMut(Self::Unwrapped) -> B; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(generic_associated_types)] | |
trait Functor { | |
type Unwrapped; | |
type Wrapped<A>: Functor; | |
fn map<F, B>(self, f: F) -> Self::Wrapped<B> | |
where | |
F: FnOnce(Self::Unwrapped) -> B; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack --resolver lts-15.10 script | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
import RIO | |
import Network.HTTP.Simple | |
import qualified RIO.Text as T | |
main :: IO () | |
main = runSimpleApp $ do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack --resolver foo.yaml script | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RecordWildCards #-} | |
import Pantry | |
import RIO | |
import Path | |
import Path.IO | |
import Data.Yaml (encodeFile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RIO | |
import Pantry | |
import Path | |
data App = App SimpleApp PantryConfig | |
instance HasPantryConfig App where | |
pantryConfigL = lens (\(App _ pc) -> pc) undefined | |
instance HasLogFunc App where | |
logFuncL = (lens (\(App sa _) -> sa) undefined).logFuncL |
NewerOlder