Created
December 20, 2018 22:34
-
-
Save scott-fleischman/9580f60f004280ddd399ac662b39d609 to your computer and use it in GitHub Desktop.
DeBruijn Haskell type class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://twitter.com/pigworker/status/1068897189227913223 | |
newtype B t = B t | |
class DeBruijn d where | |
deBruijn :: Applicative f => (s -> Int -> f t) -> d s -> Int -> f (d t) | |
instance DeBruijn B where | |
deBruijn f (B s) i = B <$> f s (i + 1) | |
deBruijnDefault = ala' Compose traverse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment