Skip to content

Instantly share code, notes, and snippets.

View cmk's full-sized avatar

Chris McKinlay cmk

View GitHub Profile
#!/usr/bin/env stack
-- stack --resolver lts-11.10 script
import Control.Monad.Trans.Class
import Control.Monad.IO.Class
import Data.Functor.Identity
newtype ReaderT r m a = ReaderT { runReaderT :: r -> m a }
instance Functor m => Functor (ReaderT r m) where
fmap f (ReaderT rma) = ReaderT $ fmap f . rma
-- | A 'Validator a b' is in particular a '(Applicative f, Choice p) => p a (f b)'.
type Validator a b = a -> Validation ValidationErrors b
-- | Lift a 'Getting (Maybe a) s (Maybe a)' into a 'Prism'. This should only be used if the
-- target domain type is a 'Maybe b'.
--
-- Note that error messages from 'Validator's consumed in this way are preserved.
--
-- @
-- 'validating' :: Getting (Maybe a) s (Maybe a) -> Validator a b -> Validator s (Maybe b)
Verifying my Blockstack ID is secured with the address 1JafhKfXbBynoUfwCLJ1r9u4ymdyaC5N9c https://explorer.blockstack.org/address/1JafhKfXbBynoUfwCLJ1r9u4ymdyaC5N9c
@cmk
cmk / Constraints.org
Created January 18, 2019 02:51 — forked from Icelandjack/Constraints.org
Type Classes and Constraints

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import Data.Bifunctor
import Data.Bifoldable
import Data.Bifunctor.Join
import Data.Biapplicative
import Data.Bitraversable

deciban

The following table lists a number of rare events, arranged on a deciban scale. The deciban is a logarithmic unit — much like the decibel or the Richter scale — introduced by Alan Turing for expressing probabilities. It is a tenth of a ban, which is also known as the base-10 log-odds.

Please note that these are only rough estimates for the purpose of providing intuition for the relative likelihood of various rare events. Many are based on population averages, and do not apply to you personally. As always, keep the above comic in mind ;)

decibans event