Skip to content

Instantly share code, notes, and snippets.

View 3noch's full-sized avatar
🕯️

Elliot Cameron 3noch

🕯️
  • Indiana
View GitHub Profile

Monads and delimited control are very closely related, so it isn’t too hard to understand them in terms of one another. From a monadic point of view, the big idea is that if you have the computation m >>= f, then f is m’s continuation. It’s the function that is called with m’s result to continue execution after m returns.

If you have a long chain of binds, the continuation is just the composition of all of them. So, for example, if you have

m >>= f >>= g >>= h

then the continuation of m is f >=> g >=> h. Likewise, the continuation of m >>= f is g >=> h.

@chrisdone
chrisdone / DBAPI.hs
Last active April 10, 2022 07:26
Defaulting fields in a record in Haskell
{-# LANGUAGE DataKinds #-}
-- | My database API.
module DBAPI where
import Data.Defaults
data ConnSpec p = ConnSpec
{ username :: !(Required p String)
@Lysxia
Lysxia / PseudoLinearTypes.hs
Created January 1, 2019 04:13
An indexed monad to count mallocs and frees
{-# LANGUAGE
DataKinds,
FlexibleInstances,
FlexibleContexts,
PolyKinds,
ScopedTypeVariables,
TypeApplications,
TypeFamilies,
TypeInType,
TypeOperators #-}
@et4te
et4te / install_nix.md
Last active June 23, 2018 17:14
Preparing for betanet launch with Nix and the Ledger Nano S

Preparing for betanet launch with Nix and Ledger Nano S

This guide is for users of the Nix package manager and assumes you have a Ledger Nano S updated with the latest firmware (at this time 1.4.2).

NOTE If you are not on NixOS, skip the sections which have NixOS at the start of the heading.

NixOS Binary Cache Configuration

To hasten the build process (it could take days to build without this), add the following to /etc/nixos/configuration.nix if you are on NixOS.

@ali-abrar
ali-abrar / bodyKeyDown.hs
Last active December 26, 2020 01:38
reflex-dom <body> key handler
{-# language PackageImports #-}
import Control.Monad
import "ghcjs-dom" GHCJS.DOM.Document (getBody)
import GHCJS.DOM.EventM (on, preventDefault)
import GHCJS.DOM.GlobalEventHandlers (keyDown)
import Reflex.Dom hiding (preventDefault)
import Web.KeyCode
main :: IO ()
main = mainWidget $ do
@nZac
nZac / Commands
Created February 21, 2018 17:43
Basic NixOS Virtualbox Setup
# Original: https://nixos.wiki/wiki/NixOS_on_ZFS#How_to_install_NixOS_on_a_ZFS_root_filesystem
# Make sure to enable EFI support in VB. Settings -> System -> Enable EFI
# Add the zfs filesystem to the install environment:
nano /etc/nixos/configuration.nix
## ---8<-------------------------8<---
boot.supportedFilesystems = [ "zfs" ];
## ---8<-------------------------8<---
@nurpax
nurpax / char-rnn.hs
Last active November 9, 2017 15:50
Some char-rnn generated Haskell based on training with the GHC HEAD source code
-- buildPatSynDetails, so this is a mempty, even the type
-- we generate the same location here.
hsConDeclDetails _ = pprPanic "tcLHsBindsCtOrigin" (ppr val_val_binds)
--------------------
zonkForeignCall :: FlexibleInfo -> CoreBind
-> Maybe FreeVars -- True <=> supplied EndBinds
-> RecFlag
-> Cts -> ForeignOpt Id
@ekmett
ekmett / Closed.hs
Created October 21, 2017 09:50
Closed kinds aren't as closed as you'd think
{-# language PolyKinds, DataKinds, RankNTypes, TypeApplications, ScopedTypeVariables, TypeFamilies, FlexibleInstances #-}
import Data.Proxy
class KnownUnit (k :: ()) where
reflect :: Proxy k -> Int
instance KnownUnit '() where
reflect _ = 0

1. vultr iso > add iso

2. upload 18.03 iso

https://d3g5gsiof5omrk.cloudfront.net/nixos/unstable/nixos-18.03pre116572.9824ca6975/nixos-minimal-18.03pre116572.9824ca6975-x86_64-linux.iso

3. deploy new server

@3noch
3noch / .ghci
Last active October 29, 2018 09:49
Reflex-DOM Auto Reload Development with ghcid
:set prompt "> "
:set -isrc
:load Main