Skip to content

Instantly share code, notes, and snippets.

View larrytheliquid's full-sized avatar

Larry Diehl larrytheliquid

View GitHub Profile
@timjb
timjb / AboutMe.mustache
Created December 1, 2013 15:27
Mustache templating in Idris
Hello, my name ist {{name}} and I am {{age}} years old.
@jonsterling
jonsterling / proofs.sml
Last active January 2, 2016 04:48
Constructive proofs in SML's module language
(* It is not possible in Standard ML to construct an identity type (or any other
* indexed type), but that does not stop us from speculating. We can specify with
* a signature equality should mean, and then use a functor to say, "If there
* were a such thing as equality, then we could prove these things with it."
* Likewise, we can use the same trick to define the booleans and their
* induction principle at the type-level, and speculate what proofs we could
* make if we indeed had the booleans and their induction principle.
*
* Functions may be defined by asserting their inputs and outputs as
* propositional equalities in a signature; these "functions" do not compute,
@callistabee
callistabee / mergesort.lhs
Last active February 10, 2021 06:39
Haskell Implementation of Mergesort
- Haskell Mergesort
- Copyright (C) 2014 by Kendall Stewart
First we define a couple of helper functions that
will be useful in splitting the list in half:
> fsthalf :: [a] -> [a]
> fsthalf xs = take (length xs `div` 2) xs
@gitaarik
gitaarik / git_submodules.md
Last active May 4, 2024 11:10
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@copumpkin
copumpkin / RuntimeTypes.agda
Last active July 24, 2018 19:01
Simulating "type providers" in Agda
module RuntimeTypes where
open import Function
open import Data.Unit
open import Data.Bool
open import Data.Integer
open import Data.String as String
open import Data.Maybe hiding (All)
open import Data.List
open import Data.List.All
@dmalikov
dmalikov / README.markdown
Last active May 31, 2019 06:31
Nix / NixOS links

Various blog posts related to Nix and NixOS


General

@edwinb
edwinb / fakechar.idr
Created August 10, 2015 13:33
Faked overloaded strings
data FakeChar = A | B | C
data ValidMyString : List Char -> Type where
VA : ValidMyString xs -> ValidMyString ('a' :: xs)
VB : ValidMyString xs -> ValidMyString ('b' :: xs)
VC : ValidMyString xs -> ValidMyString ('c' :: xs)
VNil : ValidMyString []
implicit fromString : (x : String) -> {auto p : ValidMyString (unpack x)}
-> List FakeChar
@jozefg
jozefg / PickRandom.hs
Last active August 3, 2017 13:55
A simple trick to pick a random element from a stream in constant memory
{-# LANGUAGE FlexibleContexts #-}
module PickRandom where
import Data.List (group, sort)
import Control.Monad
import Control.Monad.Random (MonadRandom, getRandomR)
import qualified Control.Foldl as F
-- Pick a value uniformly from a fold
pickRandom :: MonadRandom m => a -> F.FoldM m a a
pickRandom a = F.FoldM choose (return (a, 0 :: Int)) (return . fst)
@puffnfresh
puffnfresh / Main.idr
Created October 14, 2016 10:49
Type-safe printf, using runtime provided strings. An extension on https://gist.github.com/puffnfresh/11202637
module Main
%default total
data Format
= FInt -- %d
| FString -- %s
| FOther Char -- [a-zA-Z0-9]
format : List Char -> List Format
{-# OPTIONS --copatterns #-}
module CoList where
{- High-level intuition:
codata CoList (A : Set) : Set where
nil : CoList A
cons : A → CoList A → CoList A
append : ∀{A} → CoList A → CoList A → CoList A