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 FlexibleInstances, MultiParamTypeClasses #-} | |
module Data.Function.Variadic where | |
class Variadic a r where variadic :: (a -> a -> a) -> a -> r | |
instance Variadic a a where variadic _ = id | |
instance Variadic a r => Variadic a (a -> r) where | |
variadic f x = variadic f . f x |
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/runhaskell | |
import Control.Concurrent | |
import Control.Monad | |
import qualified Data.ByteString.Lazy as BSL | |
import Network | |
import System.IO |
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
-- | A monad transformer for generator coroutines | |
module Control.Monad.Generator where | |
import Control.Applicative | |
import Control.Monad | |
import Control.Monad.Trans | |
-- | The type of generators yielding intermediate results of type @t@ in base | |
-- monad @m@, with a final result of type @r@ | |
data Generator t m r = Generator {runGen :: m (GeneratorState t m r)} |
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 DataKinds, GADTs, KindSignatures, TemplateHaskell #-} | |
-- | Lists with type-encoded length | |
-- | |
-- Includes TH macros for concise usage of Peano naturals at type and term | |
-- level. | |
-- | |
-- Examples: | |
-- | |
-- >>> :t Nil |
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 DeriveDataTypeable, FlexibleInstances, OverlappingInstances #-} | |
module Assert where | |
import Control.Exception | |
import Data.Typeable | |
data AssertionFailure = AssertionFailure (Maybe String) deriving Typeable |
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 GeneralizedNewtypeDeriving #-} | |
module Data.Gray where | |
import Control.Applicative | |
class Binary b where zero :: b | |
one :: b | |
instance Binary Bool where zero = False |
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
-- | Mini-EDSL for RPG-style die roll specifiers | |
-- | |
-- Examples: | |
-- | |
-- > Chance> let c = 3 + 2 `d` 20 | |
-- > Chance> roll c | |
-- > 17 | |
-- > Chance> roll c | |
-- > 21 | |
-- > Chance> roll c |
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 FunctionalDependencies #-} | |
-- | Self-incrementing counters based on mutable references | |
module Counter where | |
import Control.Monad.ST | |
import Data.IORef | |
import Data.STRef |
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/runhaskell | |
{- | |
- Convert PMA commodity/variety spreadsheet from CSV to JSON | |
- | |
- Requires HP + aeson, cassava, utf8-string | |
-} | |
import Control.Applicative |
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 DataKinds | |
, GeneralizedNewtypeDeriving | |
, KindSignatures | |
, ScopedTypeVariables | |
#-} | |
-- | Modular addition with statically inferred modulus | |
-- | |
-- Usage example (with @DataKinds@ extension enabled): | |
-- |
NewerOlder