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
Prelude/Data.List/Data.Vector/Data.Map: | |
(!!) :: [a] -> Int -> a | |
replicate :: Int -> a -> [a] | |
take :: Int -> [a] -> [a] | |
drop :: Int -> [a] -> [a] | |
splitAt :: Int -> [a] -> ([a], [a]) | |
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
-- Credit to: https://news.ycombinator.com/item?id=15186988 | |
let iterate | |
: (Natural → Natural) → Natural → Natural | |
= \f n -> | |
fold (n + 1) f 1 | |
let increment : Natural → Natural = \n -> n + 1 | |
let ackermann |
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 Strict #-} | |
{-# LANGUAGE Strict #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE RankNTypes, InstanceSigs, KindSignatures, GADTs, ConstraintKinds, ScopedTypeVariables #-} | |
-- http://neilsculthorpe.com/publications/constrained-monad-problem.pdf | |
import Data.Function | |
import Data.List.NonEmpty (NonEmpty(..)) |
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 RankNTypes, InstanceSigs, KindSignatures, GADTs, ConstraintKinds, ScopedTypeVariables #-} | |
-- http://neilsculthorpe.com/publications/constrained-monad-problem.pdf | |
import GHC.Exts | |
data NAF :: (* -> Constraint) -> (* -> *) -> * -> * where | |
Pure :: a -> NAF c t a | |
Ap :: c x => NAF c t (x -> a) -> t x -> NAF c t a |
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 RankNTypes, InstanceSigs, KindSignatures, GADTs, ConstraintKinds #-} | |
-- Paper: http://neilsculthorpe.com/publications/constrained-monad-problem.pdf | |
-- Talk: https://vimeo.com/69261960 | |
import GHC.Exts | |
data NF :: (* -> Constraint) -> (* -> *) -> * -> * where | |
FMap :: c x => (x -> a) -> t x -> NF c t a |
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 RIO.ConcurrentLog where | |
import qualified Data.ByteString.Builder as SB | |
import Data.List | |
import Data.Time | |
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
applicative :: Q Exp -> [Q Exp] -> Q Exp | |
applicative cons [] = [| pure $(cons) |] | |
applicative cons (x:ys) = foldl (\inner y -> [| $(inner) <*> $(y) |]) [|$(cons) <$> $(x)|] ys |
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
-- | Conduit piping with error handling. | |
module Data.Conduit.Error where | |
import Data.Conduit.Internal | |
infixr 2 .|? | |
(.|?) :: Monad m => ConduitT a b m (Either e ()) -> ConduitT b c m (Either e r) -> ConduitT a c m (Either e r) | |
ConduitT left0 .|? ConduitT right0 = | |
ConduitT $ \rest -> |
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 LambdaCase #-} | |
-- | Sources that flush when their monadic action takes longer than n | |
-- microseconds. | |
module Data.Conduit.Flush where | |
import Data.Conduit | |
import Data.Conduit.Internal as Pipe (ConduitT(..), Pipe(..)) | |
import UnliftIO |
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 ScopedTypeVariables #-} | |
-- | A ResourceT-based way to use connections with conduit. | |
module Data.Conduit.Network.Resource where | |
import qualified Network.Socket as NS | |
import Control.Exception | |
import Control.Monad.IO.Class | |
import Control.Monad.Trans.Resource |