This file contains 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-12.21 script | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
import Control.Lens | |
import Control.Monad (replicateM) | |
import System.Random | |
import RIO |
This file contains 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-11.10 script | |
{-# LANGUAGE NoImplicitPrelude #-} | |
import RIO | |
import Conduit | |
import Control.Concurrent.STM.TBMQueue | |
doesn'tStall | |
:: MonadUnliftIO m | |
=> Int -- ^ number of microseconds |
This file contains 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 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 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 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 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 QuasiQuotes #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Yesod | |
import Yesod.OptionalSubsite | |
import Yesod.Static | |
data HelloWorld = HelloWorld | |
getStatic _ = OptionalSubsite Nothing |
This file contains 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 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 #-} | |
module FileViewer where | |
import Control.Concurrent (forkIO) | |
import Control.Monad (void) | |
import Network.Wai.Application.Static (defaultFileServerSettings, | |
staticApp) | |
import Network.Wai.Handler.Warp (run) | |
import Prelude (IO, read, ($)) |
This file contains 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-12.18 script | |
import Control.Concurrent (threadDelay) | |
import Control.Concurrent.Async (replicateConcurrently_) | |
import Control.Monad (unless) | |
import Data.IORef | |
import System.Random (randomIO) | |
main :: IO () | |
main = do |
NewerOlder