Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Le mstksg

View GitHub Profile
View wordle-allowed-guesses.txt
aahed
aalii
aargh
aarti
abaca
abaci
abacs
abaft
abaka
abamp
@mstksg
mstksg / day18trees.txt
Created Dec 18, 2019
AOC 2019 Day 18 Trees
View day18trees.txt
###############
#d.ABC.#.....a#
######...######
######.@.######
######...######
#b.....#.....c#
###############
(0,Nothing)
|
@mstksg
mstksg / letterforms.txt
Last active Dec 8, 2019
Advent of Code 2019 Day 8: "Space Image Format" Letterforms
View letterforms.txt
##
# #
# #
####
# #
# #
###
# #
###
@mstksg
mstksg / typeparsers.hs
Last active Nov 28, 2019
type-level parser combinators
View typeparsers.hs
{-# 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 Sep 30, 2021
Stack Project Github Action Template
View haskell.yml
# 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 Sep 7, 2019
ID3 homework assignment from 2015
View id3.hs
-- 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 Aug 28, 2019
backprop but using with mutable variables
View bpop-mutable.hs
#!/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 Jun 11, 2019
Promoted MuRef
View muref.hs
#!/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 Jun 19, 2018
Type-Level Lenses
View singleton_lenses.hs
ghci> :kind! View FirstFieldSym0 '(1, True)
1
ghci> :kind! Over SecondFieldSym0 NotSym0 '(1, True)
'(1, False)
View init-last.hs
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)