Skip to content

Instantly share code, notes, and snippets.

@dcastro
dcastro / slack_edit_message.json
Created May 15, 2022
slack_edit_message.json
View 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": {
View 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 Mar 5, 2022
hangzhou vs ithaca
View hangzhou.log
>>>>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 Jan 30, 2022
coffer example log
View log.md
$ 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 Mar 8, 2021
singleton-types.md
View 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 Feb 12, 2021
nix + custom build type
View log.log
$ 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 Feb 9, 2021
Doctest + mixins
View a.log
/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 Jan 18, 2021
TyFam inductive case
View rightComb.hs
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 Feb 6, 2022
Universally vs existentially quantified type variables
View universal_existential.md

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 Sep 29, 2020
Capturing type variables in TemplateHaskell
View Problem.hs
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|]