Skip to content

Instantly share code, notes, and snippets.

@dcastro
dcastro / slack_edit_message.json
Created May 15, 2022 17:28
slack_edit_message.json
{
"envelope_id": "f34c6197-a7ef-45ed-acad-4d5a3147ec86",
"payload": {
"token": "Pct6Sm6JynybrFXkjEiH7hhX",
"team_id": "T02NDBHSWSG",
"api_app_id": "A03BLN935DK",
"event": {
"type": "message",
"subtype": "message_changed",
"message": {
@dcastro
dcastro / slack_message.json
Created May 15, 2022 17:19
slack_message.json
{
"envelope_id": "012327ef-4c84-41e3-a952-09af25782c17",
"payload": {
"token": "Pct6Sm6JynybrFXkjEiH7hhX",
"team_id": "T02NDBHSWSG",
"api_app_id": "A03BLN935DK",
"event": {
"client_msg_id": "0837851c-2d34-4d4d-804c-7aed753c3421",
"type": "message",
"text": "Hello world",
@dcastro
dcastro / hangzhou.log
Created March 5, 2022 15:49
hangzhou vs ithaca
>>>>0: https://hangzhou.testnet.tezos.serokell.team/version
>>>>1: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/protocols
>>>>2: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/context/contracts/tz1ZSedNyGuqibEYCPbuMS3yEhhLHfZEuLtA/counter
>>>>3: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/context/contracts/tz1ZSedNyGuqibEYCPbuMS3yEhhLHfZEuLtA/manager_key
>>>>4: https://hangzhou.testnet.tezos.serokell.team/monitor/bootstrapped
>>>>5: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/context/constants
>>>>6: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/hash
>>>>7: https://hangzhou.testnet.tezos.serokell.team/chains/main/chain_id
>>>>8: https://hangzhou.testnet.tezos.serokell.team/chains/main/chain_id
>>>>9: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/helpers/scripts/simulate_operation
@dcastro
dcastro / log.md
Last active January 30, 2022 17:32
coffer example log
$ cabal run exe:coffer -- create diogo/google-work \
  --field user:dcastro@serokell.com \
  --field pw:123 \
  --field url:www.google.com

[SUCCESS] Entry created at '/diogo/google-work'

$ cabal run exe:coffer -- create diogo/google-home \
@dcastro
dcastro / singleton-types.md
Last active March 8, 2021 22:31
singleton-types.md

This tutorial assumes you're already familiar with Haskell's kind system and extensions like DataKinds. If not, please read my blog post first </shameless-plug>.

Say you want to model a TCP connection, and it can be in either an "open" or "closed" status.

data Connection = MkConnection ...
@dcastro
dcastro / log.log
Created February 12, 2021 11:15
nix + custom build type
$ nix-build ci.nix -A all-components --no-out-link
building '/nix/store/bflfb6jrxykrp53fkd5f0gd0d45z776s-git-ls-files.drv'...
trace: To make this a fixed-output derivation but not materialized, set `stack-sha256` to the output of /nix/store/w4f2lcmndg68m64cdrhm1vkhz2s216i7-calculateSha
trace: To materialize the output entirely, pass a writable path as the `materialized` argument and pass that path to /nix/store/y1w6r7c4wrvhllzmz4k3h6g30b4hph74-generateMaterialized
building '/nix/store/36nhcnn93ik0zdsmbcbrpqbq0ajl5lsc-morley-stack-to-nix-pkgs.drv'...
substituteStream(): WARNING: pattern '/nix/store/fn96af9026mkyk28pj3ivwd9drzd247m-morley' doesn't match anything in file '/nix/store/zyzl3v6lww8a81qhmv052075a4qbbj7n-morley-stack-to-nix-pkgs/default.nix'
substituteStream(): WARNING: pattern '/nix/store/fn96af9026mkyk28pj3ivwd9drzd247m-morley' doesn't match anything in file '/nix/store/zyzl3v6lww8a81qhmv052075a4qbbj7n-morley-stack-to-nix-pkgs/pkgs.nix'
these derivations will be built:
@dcastro
dcastro / a.log
Created February 9, 2021 16:36
Doctest + mixins
/home/dc/.ghcup/bin/ghc --make -fbuilding-cabal-package -O -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir /home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build -odir /home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build -hidir /home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build -stubdir /home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build -i -i/home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build -isrc -i/home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build/autogen -i/home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0.0/build/global-autogen -I/home/dc/dev/other/doctest-mixins/dist-newstyle/build/x86_64-linux/ghc-8.8.3/doctest-mixins-0.1.0
@dcastro
dcastro / rightComb.hs
Last active January 18, 2021 16:02
TyFam inductive case
import Data.Vinyl (Rec(..))
data Tag = TagInt | TagPair Tag Tag
data Exp (t :: Tag) where
EInt :: Int -> Exp 'TagInt
EPair :: Exp t1 -> Exp t2 -> Exp ('TagPair t1 t2)
type family RightComb (tags :: [Tag]) :: Tag where
RightComb '[ x, y ] = 'TagPair x y
@dcastro
dcastro / universal_existential.md
Last active February 6, 2022 07:55
Universally vs existentially quantified type variables

A type variable can be either universally ("for all x, then ...") or existentially quantified ("there exists some x, ...").

(If you're a maths persons, this corresponds to ∀x. x and ∃x. x, respectively)

In haskell, universally quantified type vars are represented with a forall:

head :: forall a. [a] -> Maybe a
@dcastro
dcastro / Problem.hs
Last active September 29, 2020 08:20
Capturing type variables in TemplateHaskell
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
module Problem where
data PP a where
PP :: forall a. Typeable a => PP a
instance Lift (PP a) where
lift PP = [|PP|]