Skip to content

Instantly share code, notes, and snippets.

View joshvera's full-sized avatar
🔥
intros nightingale.

Josh Vera joshvera

🔥
intros nightingale.
View GitHub Profile
@pamolloy
pamolloy / README.md
Last active January 23, 2024 07:28
Ubiquiti USG configuration for Wireguard

Download the latest ugw3 package from https://github.com/Lochnair/vyatta-wireguard/releases and install it on your USG using dpkg -i wireguard-ugw3-<version>.deb.

cd /config/auth
umask 077
mkdir wireguard
cd wireguard
wg genkey > wg_private.key
wg pubkey < wg_private.key > wg_public.key
@phadej
phadej / poly-nfdata.hs
Last active November 6, 2017 22:24
Example how is possible to write polykinded type-classes in GHC-8.0. It's not that bad or messy, but I'm not sure it's practical either.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
@avieth
avieth / gist:334201aa341d9a00c7fc
Last active July 22, 2022 13:42
Interpreting Free Monads of Functor Sums
Interpreting Free Monads of Functor Sums
========================================
This text deals with a way to compose certain kinds of monads, thereby mixing
their capabilities. It is a literate Haskell file, so let's begin with a
bunch of noise.
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE FlexibleContexts #-}
@nkpart
nkpart / Err.hs
Last active August 20, 2022 01:20
Lens, Prisms, and Errors.
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fwarn-missing-methods #-}
module Err where
import Control.Lens
import Control.Monad.Error
import Control.Monad.Error.Lens
-- Here is a fairly typical situation, where we have low level errors in certain
@mrb
mrb / Tiger.idr
Created October 24, 2014 15:04
A little straight line program interpreter I implemented from the "modern compiler implementation in ML" book by Appel
module Main
import Control.Monad.Writer
Id : Type
Id = String
data Binop = Plus | Minus | Times
mutual
@paf31
paf31 / Deriv.idr
Last active July 20, 2017 07:14
Calculus of types in idris
module Deriv
import Control.Isomorphism
--
-- A type constructor df is the derivative of the type constructor f if for all x and e there exists d such
-- such that
--
-- f (x + e) ~ f x + e * (df x) + e^2 * d
--
@CodaFi
CodaFi / Monards.md
Last active November 27, 2017 07:45
Monads Made Hard, Then Simple, Then Easy

##A (Haskell) Monad Is...

A monoid in the category of endofunctors...

Such that the following diagrams commute

##Mu Reduction

 μT
@gelisam
gelisam / Main.hs
Last active August 22, 2022 18:18
IndexedMonad example
-- in reply to http://www.reddit.com/r/haskell/comments/21mja6/make_lllegal_state_transitions_unrepresentable/
--
-- We implement a tiny language with three commands: Open, Close, and Get.
-- The first Get after an Open returns 1, the second Get returns 2, and so on.
--
-- Get is only valid while the state is open, and
-- Open must always be matched by a Close.
-- We enforce both restrictions via the type system.
--
-- There are two valid states: Opened and Closed.
@chpatrick
chpatrick / marshal.hs
Last active August 29, 2015 13:57
Automatic type-safe binding generation sketch (GHC HEAD)
{-# LANGUAGE TypeFamilies, GADTs, DataKinds, TypeOperators, FlexibleInstances, OverlappingInstances, ConstraintKinds, MultiParamTypeClasses, ForeignFunctionInterface #-}
import Control.Applicative
import Foreign
import Foreign.C
-- heterogenous list
data HList (ts :: [ * ]) where
E :: HList '[]
(:.) :: t -> HList ts -> HList (t ': ts)
@mxswd
mxswd / Main.hs
Last active August 29, 2015 13:57
{-# LANGUAGE DataKinds, TemplateHaskell, TypeFamilies, QuasiQuotes #-}
import TICTACTOE
game :: ([tq| x o x
o o x
☐ ☐ x |])
game = (?)