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
| data Balance = | |
| Balance !Int | |
| !Int | |
| deriving (Eq, Show) | |
| instance Semigroup Balance where | |
| Balance a b <> Balance c d | |
| | b <= c = Balance (a + c - b) d | |
| | otherwise = Balance a (d + b - c) |
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
| module ExpandMap | |
| ( expandIntMap | |
| ) where | |
| import Control.Monad.State (evalState, get, put) | |
| import Data.IntMap (IntMap) | |
| import qualified Data.IntMap as IntMap | |
| import Data.Traversable (for) | |
| -- >>> expandIntMap '0' 50 (IntMap.fromList (zip [0,5..50] ['a' .. 'z'])) |
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
| -- To run: | |
| -- $ nix-shell -p "haskellPackages.ghcWithPackages (ghc: [ghc.reactive-banana])" --run "runhaskell ./Main.hs" | |
| module Main where | |
| import Control.Concurrent (threadDelay) | |
| import Control.Event.Handler (newAddHandler) | |
| import Control.Monad (replicateM_) | |
| import Reactive.Banana.Combinators | |
| ( Event |
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 NoImplicitPrelude #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| module List where | |
| import Data.Bool (Bool) | |
| import Data.Function (const) | |
| import Data.Ord ((<=)) | |
| import GHC.Int (Int) | |
| import GHC.Num ((-)) |
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
| module BankersQueue where | |
| import Prelude hiding (head, tail) | |
| data Queue a = | |
| Queue [a] !Int [a] !Int | |
| deriving (Show) | |
| empty :: Queue a | |
| empty = Queue [] 0 [] 0 |
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 GADTs #-} | |
| {-# LANGUAGE StandaloneDeriving #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| module Main where | |
| import Data.Function ((&)) | |
| data Locked |
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 KindSignatures #-} | |
| {-# LANGUAGE NoImplicitPrelude #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| module Data.Constrained | |
| ( Constrained(unconstrained) | |
| , constrain | |
| ) where | |
| import Data.Bool ((&&), otherwise) |
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 DataKinds #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE ExplicitNamespaces #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| module Data.Text.Sized | |
| ( Text |
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
| module Main where | |
| import Data.Bool (bool) | |
| import Control.Monad ((<=<)) | |
| import Control.Monad.State (State, evalState, get, put) | |
| import Data.Char (isSpace) | |
| import Data.Foldable (traverse_) | |
| import Data.Functor.Compose (Compose(Compose, getCompose)) | |
| import Data.Functor.Const (Const(Const, getConst)) | |
| import Data.Functor.Product (Product(Pair)) |
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
| module Main where | |
| import Data.Functor (void) | |
| import Control.Applicative ((<|>), empty, many, some, optional) | |
| import Control.Monad (msum, replicateM) | |
| import Control.Monad.State (StateT(runStateT)) | |
| import Control.Monad.State.Class (get, put) | |
| import Data.Char (isHexDigit, chr, isDigit, isSpace) | |
| import Data.Map (Map) | |
| import Data.Maybe (listToMaybe, fromMaybe) |