Skip to content

Instantly share code, notes, and snippets.

@chrisdone
chrisdone / cell-load.hs
Last active May 4, 2022 08:45
Document cell-load pipeline
-- | Load a renamed cell.
resolveRenamedCell ::
Map Hash (Either LoadError LoadedExpression)
-> FillerEnv LoadError
-> IsRenamed (Expression Renamed)
-> RIO DocumentReader (Either LoadError (IsResolved (Expression Resolved)))
resolveRenamedCell globalTypes globalHashes isRenamed = do
hasConstraints <-
pure $
first LoadGenerateError $
@chrisdone
chrisdone / Basic type solver tests.hs
Created May 2, 2022 13:52
Basic unification tests for type checkers
fineGrained :: Spec
fineGrained = do
describe
"Successful"
(do it "a ~ a" (shouldReturn (unifyConstraints' [a .~ a]) (pure []))
it
"Integer ~ Integer"
(shouldReturn (unifyConstraints' [_Integer .~ _Integer]) (pure []))
it
"a ~ b"
22-03-21 13:32:52.939 $ cat /opt/hindent-ormolu
#!/bin/bash
/opt/ormolu-0.1.4.1 \
"--ghc-opt" "-XBangPatterns" \
"--ghc-opt" "-XNumericUnderscores" \
"--ghc-opt" "-XOverloadedLabels" \
"--ghc-opt" "-XPatternSynonyms" \
"--ghc-opt" "-XTypeApplications" \
"--mode" "stdout"

Installing a TLS SSL certificate in HAProxy from Namecheap - Sectigo Limited certificate

When buying an SSL certificate from Namecheap, you generate a CSR, which generates a private key, save that for later as private.key.

After you've paid for your certificate, you recieve a zip file that looks like this:

$ ls -alh
total 52K
@chrisdone
chrisdone / Int-taking-funcs.hs
Created June 13, 2020 16:05
Int-taking-functions
Prelude/Data.List/Data.Vector/Data.Map:
(!!) :: [a] -> Int -> a
replicate :: Int -> a -> [a]
take :: Int -> [a] -> [a]
drop :: Int -> [a] -> [a]
splitAt :: Int -> [a] -> ([a], [a])
@chrisdone
chrisdone / 0README.md
Last active March 22, 2024 12:41
Various type inference designs/sketches

Type Inference: Various Designs

I'm exploring the right data types for writing a type inference with higher kinds and poly types.

Putting more things in the type system can force you to think about more things, but it also can make it harder and more verbose to write and read algorithms.

@chrisdone
chrisdone / types.hs
Last active June 11, 2022 23:43
types
{-# LANGUAGE TypeOperators, LambdaCase, StandaloneDeriving, GADTs #-}
data Type env t where
-- A constant type. Add kinds?
-- Maybe, (), Int, Either, (->), etc.
Constructor :: kind -> Type env kind
-- A free variable.
-- a
FreeVariable :: kind -> Type env kind
-- Type application.
@chrisdone
chrisdone / ackermann.dhall
Last active April 7, 2020 09:02 — forked from Gabriella439/ackermann.dhall
Ackermann function in Dhall
-- Credit to: https://news.ycombinator.com/item?id=15186988
let iterate
: (Natural → Natural) → Natural → Natural
= \f n ->
fold (n + 1) f 1
let increment : Natural → Natural = \n -> n + 1
let ackermann
@chrisdone
chrisdone / normalized applicative.hs
Last active March 20, 2020 11:57
normalized applicative.hs
{-# LANGUAGE Strict #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE RankNTypes, InstanceSigs, KindSignatures, GADTs, ConstraintKinds, ScopedTypeVariables #-}
-- http://neilsculthorpe.com/publications/constrained-monad-problem.pdf
import Data.Function
import Data.List.NonEmpty (NonEmpty(..))
@chrisdone
chrisdone / Control.Applicative.Normalized.hs
Created March 20, 2020 10:20
Control.Applicative.Normalized.hs
{-# LANGUAGE RankNTypes, InstanceSigs, KindSignatures, GADTs, ConstraintKinds, ScopedTypeVariables #-}
-- http://neilsculthorpe.com/publications/constrained-monad-problem.pdf
import GHC.Exts
data NAF :: (* -> Constraint) -> (* -> *) -> * -> * where
Pure :: a -> NAF c t a
Ap :: c x => NAF c t (x -> a) -> t x -> NAF c t a