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 FlexibleContexts #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module JSON_RPC where | |
import ReadExcept |
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 #-} | |
{-# LANGUAGe FlexibleContexts #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
module ReadExcept ( | |
module ReadExcept | |
, module Control.Monad.Reader | |
, module Control.Monad.Except | |
, module Control.Monad.Identity | |
) where |
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 UnicodeSyntax #-} | |
{-# LANGUAGE TupleSections #-} | |
module Caesar where | |
import Data.Map (Map, fromList, fromListWith, unionWith) | |
import Data.Char | |
import Data.List | |
import Data.Function | |
encode ∷ Int → String → String |
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 FlexibleContexts, BangPatterns #-} | |
import Data.IntMap.Strict | |
import Data.Maybe | |
import Data.Function | |
import Control.Monad.Identity | |
import Control.Monad.State.Lazy hiding (fix) | |
import Prelude hiding (lookup) |
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 TypeFamilies, DataKinds, KindSignatures, GADTs #-} | |
{- TypeFamilies is required to define type-level functions -} | |
data Nat = Zero | Succ Nat | |
data Fin :: Nat -> * where | |
FZero :: Fin ('Succ n) | |
FSucc :: Fin n -> Fin ('Succ n) | |
data Vector (a :: *) :: Nat -> * where |
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 FlexibleContexts, FlexibleInstances #-} | |
{-# LANGUAGE TypeInType , ScopedTypeVariables , TypeFamilies, TypeOperators #-} | |
{-# LANGUAGE GADTs, StandaloneDeriving #-} | |
{-# LANGUAGE Safe #-} | |
module Unification where | |
import Data.Kind | |
import Prelude hiding ((++)) |
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 DeriveGeneric #-} | |
{- Building a tree based on its bfs result. -} | |
module BFS where | |
import Test.QuickCheck hiding ((><)) | |
import GHC.Generics | |
import Generic.Random | |
import Data.Sequence (Seq (..), singleton, (><)) |
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 ViewPatterns #-} | |
{-# LANGUAGE PatternSynonyms #-} | |
import Data.Vector as V | |
pattern Empty :: Vector a | |
pattern Empty <- (V.null -> True) where Empty = V.empty | |
uncons :: Vector a -> Maybe (a, Vector a) | |
uncons Empty = 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
{-# LANGUAGE TypeApplications #-} | |
import Test.QuickCheck | |
import Data.List (sort) | |
selectOrigin k = (!! k) . sort | |
select :: (Ord a) => Int -> [a] -> a | |
select k (x:xs) = case compare k n of | |
LT -> select k ys | |
EQ -> 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
{-# LANGUAGE ViewPatterns, PatternSynonyms #-} | |
module Deque where | |
import Text.Read | |
import Data.Bifunctor | |
import Prelude hiding (length, init, tail, last, head) | |
import qualified Prelude as P | |
data Deque a = |
OlderNewer