Skip to content

Instantly share code, notes, and snippets.

View nkpart's full-sized avatar

Nick Partridge nkpart

  • Brisbane, Australia
View GitHub Profile
@nkpart
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
nkpart / fmap.md
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
nkpart / info.md
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.

Haskell:

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

runMe :: IO ()
runMe =
\version "2.18.2"
\header{
title = "Cam's Clootch is Awee"
composer = "Partro"
}
\include "common.ly"
\paper {
@nkpart
nkpart / Joining CSV Tables in Haskell.md
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
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/
          tools/work-project/

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

∴ cabal new-build
@nkpart
nkpart / Yolo.hs
Last active September 5, 2018 13:50
{-# LANGUAGE GADTs #-}
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 veitchlister.com.au, 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/github.com/junegunn/fzf'
Plug 'junegunn/fzf.vim'
" Plug 'nbouscal/vim-stylish-haskell'
Plug 'alx741/vim-hindent'