Skip to content

Instantly share code, notes, and snippets.

@soupi
soupi / kinds.hs
Last active July 17, 2024 14:04
Kind inference using unification-base constraint solving.
#!/usr/bin/env cabal
{- cabal:
build-depends: base, mtl, containers, uniplate
ghc-options: -Wall
-}
-- | An example of a kind inference for data types using
-- unification-based constraint solving.
--
-- See the blog post:
@soupi
soupi / Lisp.hs
Last active October 30, 2023 10:45
A transpiler from a simple S-expression language to JS
{-# LANGUAGE LambdaCase #-}
-- http://gilmi.xyz/post/2016/10/14/lisp-to-js
module Main where
import Control.Applicative (Alternative, empty, (<|>))
import Control.Arrow (first, (***))
import Data.Bool (bool)
import Data.List (intercalate)
@soupi
soupi / kinds.hs
Created October 10, 2023 09:02
kind inference with rows/variants
#!/usr/bin/env cabal
{- cabal:
build-depends: base, mtl, containers, uniplate
ghc-options: -Wall
-}
-- | An example of a kind inference for data types using
-- unification-based constraint solving.
--
@soupi
soupi / CS.org
Last active August 22, 2022 20:18
@soupi
soupi / git.org
Last active June 28, 2022 16:37
Beginners Git Guide

Beginner’s Git

What is Git?

Git is a very popular Version Control system. A version control system is used to manage software projects. It lets you save the state of your code at different stages/versions so that you can have a ‘history’ of it, it let’s you compare changes throughout the history, have remote backups, collaborate with other people, and a lot more.

Other alternatives to git exist: Mercurial, VCS, SVN, TFS, Darcs, and more. But git is by far the most popular one so might as well learn that.

@soupi
soupi / eval_with_reader.hs
Last active January 21, 2022 16:23
How to use Reader and IORef for static scope and mutation
{-# options_ghc -Wall #-}
{-# language LambdaCase #-}
-- | Run repl with:
--
-- > cabal repl --build-depends containers --build-depends mtl
--
-- or
--
-- > stack exec --package containers --package mtl -- ghci
@soupi
soupi / upload.hs
Created November 13, 2021 14:32
upload a file to http server
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Web.Scotty
import Control.Monad.IO.Class
import Network.Wai.Middleware.RequestLogger
import Network.Wai.Middleware.Static
import Network.Wai.Parse
@soupi
soupi / Main.purs
Created December 5, 2015 21:37
simple purescript-signal + purescript-canvas example
module Main where
import Prelude
import Data.Maybe
import Control.Monad.Eff
import Graphics.Canvas as C
import Signal as S
import Signal.DOM as S
@soupi
soupi / moving-gc.txt
Last active January 25, 2021 21:47
output of -sstderr for running nyx-game with --nonmoving-gc
5,249,078,184 bytes allocated in the heap
234,375,952 bytes copied during GC
9,022,600 bytes maximum residency (8 sample(s))
1,733,392 bytes maximum slop
24 MiB total memory in use (0 MB lost due to fragmentation)
Tot time (elapsed) Avg pause Max pause
Gen 0 5100 colls, 0 par 0.323s 0.328s 0.0001s 0.0005s
Gen 1 8 colls, 0 par 0.020s 0.020s 0.0025s 0.0056s