Skip to content

Instantly share code, notes, and snippets.

View mstksg's full-sized avatar

Justin Le mstksg

View GitHub Profile
aahed
aalii
aargh
aarti
abaca
abaci
abacs
abaft
abaka
abamp
@mstksg
mstksg / day18trees.txt
Created December 18, 2019 11:02
AOC 2019 Day 18 Trees
###############
#d.ABC.#.....a#
######...######
######.@.######
######...######
#b.....#.....c#
###############
(0,Nothing)
|
@mstksg
mstksg / letterforms.txt
Last active December 8, 2019 09:38
Advent of Code 2019 Day 8: "Space Image Format" Letterforms
##
# #
# #
####
# #
# #
###
# #
###
@mstksg
mstksg / typeparsers.hs
Last active November 28, 2019 21:58
type-level parser combinators
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
-- Type-level parser combinators for parsing type-level token streams
--
-- See this in action at https://github.com/mstksg/typelits-printf/blob/047682afaba97a4a67197a8deb44fb8ee83b87a7/src/GHC/Typelits/Printf/Parse.hs
@mstksg
mstksg / haskell.yml
Last active September 30, 2021 08:16
Stack Project Github Action Template
# Haskell stack project Github Actions template
# https://gist.github.com/mstksg/11f753d891cee5980326a8ea8c865233
#
# To use, mainly change the list in 'plans' and modify 'include' for
# any OS package manager deps.
#
# Currently not working for cabal-install >= 3
#
# Based on https://raw.githubusercontent.com/commercialhaskell/stack/stable/doc/travis-complex.yml
#
@mstksg
mstksg / id3.hs
Created September 7, 2019 00:51
ID3 homework assignment from 2015
-- Instructions for running
--
-- If GHC haskell is installed:
--
-- $ runhaskell id3.hs
--
-- Have fun!
--
-- On some occasions, 'containers' package might need to be installed;
-- in that case, install with
@mstksg
mstksg / bpop-mutable.hs
Created August 28, 2019 00:37
backprop but using with mutable variables
#!/usr/bin/env stack
-- stack --install-ghc ghci --package ad --package lens --package vinyl --package reflection --package tagged --package transformers --package vector
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
@mstksg
mstksg / muref.hs
Created June 11, 2019 05:05
Promoted MuRef
#!/usr/bin/env stack
-- stack --install-ghc ghci --package data-reify
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Reify
@mstksg
mstksg / singleton_lenses.hs
Last active June 19, 2018 01:20
Type-Level Lenses
ghci> :kind! View FirstFieldSym0 '(1, True)
1
ghci> :kind! Over SecondFieldSym0 NotSym0 '(1, True)
'(1, False)
@mstksg
mstksg / init-last.hs
Created June 6, 2018 07:34
Init and Last
import Data.Bifunctor (first)
import Data.List (foldl')
type Diff a = [a] -> [a]
match :: [a] -> Either () ([a], a)
match = (fmap . first) ($[]) -- extract the Diff list
. foldl' go (Left ())
where
go :: Either () (Diff a, a)