import sys | |
def wait_for_enter(): | |
input("Press Enter to continue: ") | |
def create_ssh_keys(context): | |
"""Run: | |
ssh-keygen -t rsa -f ~/{username} | |
""" | |
pass |
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
.
#!/bin/sh | |
# --- check which is the second monitor, if any --- | |
if xrandr | grep -q "HDMI1 connected" | |
then | |
monitor=HDMI1 | |
elif xrandr | grep -q "^DP1 connected" | |
then | |
monitor=DP1 |
-- A concrete use case for the type which is to '(->)' as 'Day' is to '(,)'. | |
-- I call it "FunDay", but I don't know what its proper name is. I've been | |
-- trying to find a use for 'FunDay', and I think I've found a pretty neat one. | |
{-# LANGUAGE FlexibleContexts, FlexibleInstances, PolyKinds, RankNTypes, TypeSynonymInstances #-} | |
module Main where | |
import Test.DocTest | |
import Control.Monad.Except | |
import Control.Monad.Reader |
{-# LANGUAGE TypeOperators, PatternSynonyms, ExplicitNamespaces #-} | |
{-# LANGUAGE LambdaCase, BlockArguments #-} | |
module Select | |
( type (-?)(Fun, Const, Lazy, unLazy), ($?) | |
, Selective(..) | |
, select, branch, whenS, ifS, whileS, fromMaybeS | |
, (<||>), (<&&>), anyS, allS | |
, Monad(..) | |
) where |
#include <time.h> // Robert Nystrom | |
#include <stdio.h> // @munificentbob | |
#include <stdlib.h> // for Ginny | |
#define r return // 2008-2019 | |
#define l(a, b, c, d) for (i y=a;y\ | |
<b; y++) for (int x = c; x < d; x++) | |
typedef int i;const i H=40;const i W | |
=80;i m[40][80];i g(i x){r rand()%x; | |
}void cave(i s){i w=g(10)+5;i h=g(6) | |
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u |
Someone asked whether or not acid-state
was production ready. I shared my experiences:
parsonsmatt [11:32 AM] @nikolap it's used by cardano-wallet and Hackage. Based on my experience with acid-state, I'd say it is not a good choice for production data storage. For local desktop apps, SQLite is a much better choice, and for real production apps, Postgresql is king.
parsonsmatt [11:44 AM] acid-state did not have a test suite, at all, until I implemented the very first tests (for TemplateHaskell code generation) earlier this year. It has picked up some tests since then, but I'm still not confident in it's correctness.
It claims to be resilient to unplugging the power cord, but I doubt that, as it's not resilient to Ctrl-C
: acid-state/acid-state#79
(previous Yoneda blog) (reddit) (twitter)
Let's explore the Yoneda lemma. You don't need to be an advanced Haskeller to understand this. In fact I claim you will understand the first section fine if you're comfortable with map
/fmap
and id
.
I am not out to motivate it, but we will explore Yoneda at the level of terms and at the level of types.
import uuid | |
import json | |
# Returns a python dictionary given a file containing a JSON-based | |
# component definition. Every definition *must* contain a 'type' | |
# and 'schema' field inside a top-level dictionary. Here is an | |
# example of a simple schema file that defines a 'meta' component | |
# containing a 'name' field. | |
# |