Skip to content

Instantly share code, notes, and snippets.

View msmorgan's full-sized avatar

Michael Morgan msmorgan

View GitHub Profile
module NotElem
import Data.Vect
%default Total
NotElem : (x : a) -> Vect n a -> Type
NotElem x ys = Not (Elem x ys)
notElem : DecEq a => (x : a) -> (ys : Vect n a) -> Dec (NotElem x ys)
module MyModule
import Text.Parser
%hide Prelude.Applicative.(<|>)
%rename Text.Parser.(<||>) (<|>)
module InfixrBooleanOps
%default total
factorial : Nat -> Integer
factorial Z = 1
factorial (S n) = (cast (S n)) * factorial n
infixr 4 &&>, ||>
module ComparisonChain
%access public export
infixl 6 |==|, |/=|
infixl 6 |<|, |<=|, |>=|, |>|
namespace Interfaces
interface ChainEq ty where
(|==|) : ty -> ty -> Bool
@msmorgan
msmorgan / ChainedComparison.idr
Created October 17, 2017 19:07
src/Idris/Core/CaseTree.hs:(701,1)-(710,51): Non-exhaustive patterns in function varRule
module Control.ChainedComparison
%default total
%access export
public export
data Direction = Ascending | Descending
data ComparisonChain : Direction -> Type -> Type where
Vacuous : ComparisonChain d ty
module Data.String.Extra
%access public export
%default total
||| Remove the first `n` characters from a string. Returns the empty string if
||| the input string is too short.
drop : (n : Nat) -> (input : String) -> String
drop n str = substr n (length str) str
||| Recognises JSON string literals.
module Language.JSON.String
import Data.String.Extra
import Text.Lexer
import Text.Lexer.Util
import Text.Parser
%default total
%access private
||| Utilities functions for contitionally delaying values.
module Control.Delayed
%default total
||| Type-level function for a conditionally infinite type.
public export
inf : Bool -> Type -> Type
inf True a = Inf a
inf False a = a
module Text.Lexer.Bikeshedding
{-
Other choices include:
-:, $:
!=>, $=>
:>, :$>
#^, *! -- not really
module Text.Parser.Core
{-
...
-}
-- what to name this?
mapToken : (tokB -> tokA) -> Grammar tokA c a -> Grammar tokB c a
mapToken f (Empty val) = Empty val
mapToken f (Terminal g) = Terminal (g . f)