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
{-# OPTIONS_GHC -Wall #-} | |
module Theseus.Parser where | |
import Theseus.Lexer | |
import Theseus.Syntax | |
import Data.List as List | |
import Data.Char as Char |
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 BangPatterns #-} | |
{-# LANGUAGE MagicHash #-} | |
{-# OPTIONS_GHC -O2 #-} | |
{-# OPTIONS_GHC -funbox-strict-fields #-} | |
{-# OPTIONS_GHC -Wall #-} | |
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-} | |
module Prime (primeFast) where |
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
class (Bifunctor f) => Biapplicative f where | |
bipure :: a -> b -> f a b | |
biap :: f (a -> b) (c -> d) -> f a c -> f b d | |
class (Bifunctor l, Bifunctor r) => Bimonad l r where | |
bireturnl :: a -> l a b | |
bireturnr :: b -> r a b | |
bijoinl :: l (l a b) (r a b) -> l a b | |
bijoinr :: r (l a b) (r a b) -> r a b |
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 PolyKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module ComposeN where | |
type family FunctionType (as :: [k]) (r :: k) :: k where | |
FunctionType '[] r = r | |
FunctionType (a ': as) r = a -> FunctionType as r |
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 PolyKinds #-} | |
class Semiring a where | |
zero :: a | |
one :: a | |
plus :: a -> a -> a | |
times :: a -> a -> a | |
class SemiringForall (f :: k -> *) where |
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
(??) :: b -> b -> Bool -> b | |
a ?? b = \x -> if x then a else b | |
andM :: (Monad m) => m Bool -> m Bool -> m Bool | |
andM a b = a >>= \x -> (b ?? pure x) x | |
shortCircuitOnFalse :: (Foldable t, Monad m) => t (m Bool) -> m Bool | |
shortCircuitOnFalse = foldr andM (pure True) |
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 GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module Data.Relation where | |
import Control.Lens.Fold | |
import Prelude hiding (id, Num(..)) | |
import qualified Prelude as P | |
import Data.Foldable (foldlM) |
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 BangPatterns #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DeriveTraversable #-} | |
module Data.Diet.Map where | |
import qualified Data.Sequence as Seq | |
import Data.Sequence (Seq, ViewL(..), (<|), (><)) |
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
import Data.List (partition) | |
average2 :: (Fractional a) => a -> a -> a | |
average2 x y = (x + y) / 2 | |
median :: Ord a => [a] -> Maybe a | |
median xs | |
| even n = Nothing | |
| otherwise = select (n `div` 2) xs | |
where |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" | |
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" height="340" width="482" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.11.1"><path d="M 0.0000,340.0000 L 113.0000,170.0000 L 0.0000,0.0000 L 85.0000,0.0000 L 198.0000,170.0000 L 85.0000,340.0000 L 0.0000,340.0000 ZM 0.0000,340.0000 " fill="#352950"/><path d="M 113.0000,340.0000 L 226.0000,170.0000 L 113.0000,0.0000 L 198.0000,0.0000 L 425.0000,340.0000 L 340.0000,340.0000 L 269.0000,234.0000 L 198.0000,340.0000 L 113.0000,340.0000 ZM 113.0000,340.0000 " fill="#4A3A74"/><path d="M 387.0000,241.0000 L 350.0000,184.0000 L 482.0000,184.0000 L 482.0000,241.0000 L 387.0000,241.0000 ZM 387.0000,241.0000 " fill="#7C3679"/><path d="M 331.0000,156.0000 L 293.0000,99.0000 L 482.0000,99.0000 L 482.0000,156.0000 L 331.0000,156.0000 ZM 331.0000,156.0000 " fill="#7C3679"/></svg> |