Skip to content

Instantly share code, notes, and snippets.

View nkpart's full-sized avatar

Nick Partridge nkpart

  • Brisbane, Australia
View GitHub Profile
nkpart / Err.hs
Last active August 20, 2022 01:20
Lens, Prisms, and Errors.
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fwarn-missing-methods #-}
module Err where
import Control.Lens
import Control.Monad.Error
import Control.Monad.Error.Lens
-- Here is a fairly typical situation, where we have low level errors in certain
nkpart /
Last active September 10, 2020 04:47
fmap . fmap . fmap

fmap . fmap . fmap

Functors and Traversables compose.

You might have seen this statement before. This is how you can take advantage of it.

Composing many fmap calls gives you a function that will drill down into a structure and modify it at a certain depth in that nested structure.

nkpart /
Last active February 25, 2020 03:57
Issues calling C function from Haskell on aarch64

Using GHC 8.8.1 cross compiler, targeting aarch64-apple-ios.


type ArgType = Int32
foreign import ccall safe "f32" f32 :: ArgType -> ... 31 more times -> IO ()

runMe :: IO ()
runMe =
\version "2.18.2"
title = "Cam's Clootch is Awee"
composer = "Partro"
\include ""
\paper {
nkpart / Joining CSV Tables in
Last active June 27, 2019 16:27
Joining CSV Tables in Haskell

Joining CSV Tables in Haskell

This article describes a technique for joining (in an SQL-style) lists of haskell data structures.

Maybe not the fastest, maybe not the smartest, but it works.

Why I like it

nkpart / gist:cc852b43d948a33a04c8
Last active June 18, 2019 14:01
Using ghcid inside of emacs
Pieces you need:
* emacs
* ghcid
ghcid needs to know the height of the terminal, we'll set it explicitly
height = (window-height) - (scroll-margin) - 1
set this height as your term-buffer-maximum-size
∴ cat cabal.project
packages: tools/work-common/

I did the expected thing, and tried to build everything:

∴ cabal new-build
nkpart / Yolo.hs
Last active September 5, 2018 13:50
module Yolo where
import System.IO.Unsafe
class Yolo f where
yolo :: f a -> a
instance Yolo Maybe where
yolo (Just x) = x

nkpart: Why haskell? Super cheap upgrades. Major compiler versions, major library versions, no worries.

parqit: @nkpart can you please elaborate on "cheap"?

For sure!

At, we use a mix of Haskell and Ruby (with a smattering of Java and C++ around as well). As you can imagine, there are stark difference when you are maintaining code across these ecosystems! We have been doing this for a few years now, such that we have code in all languages that has been around for at least a few years, and we've been through large refactors, system upgrades and dependency upgrades in each.

call plug#begin('~/.local/share/nvim/plugged')
Plug 'rafi/awesome-vim-colorschemes'
Plug 'NLKNguyen/papercolor-theme'
Plug '/nix/store/dwxiva3adj5931g49scw9zip64n8ip9i-fzf-0.17.3/share/go/src/'
Plug 'junegunn/fzf.vim'
" Plug 'nbouscal/vim-stylish-haskell'
Plug 'alx741/vim-hindent'