Skip to content

Instantly share code, notes, and snippets.

View chessai's full-sized avatar

chessai chessai

View GitHub Profile
{-# 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)
(??) :: 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)
{-# 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
{-# 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
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
{-# 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
{-# OPTIONS_GHC -Wall #-}
module Theseus.Parser where
import Theseus.Lexer
import Theseus.Syntax
import Data.List as List
import Data.Char as Char
{-# language BangPatterns #-}
{-# language DataKinds #-}
{-# language GADTs #-}
{-# language KindSignatures #-}
{-# language MagicHash #-}
{-# language NoImplicitPrelude #-}
{-# language ScopedTypeVariables #-}
{-# language StandaloneDeriving #-}
{-# language TypeFamilies #-}
{-# language TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Data.Type.Ord
( Compare
, OrdCase
, IsEQ
, IsLT
{ package ? "interface" , test ? false, frontend ? false }:
let fetchNixpkgs = import ./fetchNixpkgs.nix;
nixpkgs = fetchNixpkgs {
rev = "eb857611378576f96022867a9fd15a7a841e518c";
sha256 = "0gnlxsmc7gi06dqlij1bgmcias83isldrvydw4688qpm8h4wdf44";
};
pkgs = import nixpkgs { config = {}; };
fetch-github-json = owner: repo: path:
let commit = builtins.fromJSON (builtins.readFile path);