Created
October 18, 2022 03:36
-
-
Save LSLeary/7e551b7ca6f26fa9d8ed26f718f9f78d to your computer and use it in GitHub Desktop.
Zippy Heterogeneous Lists
This file contains 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
{-# LANGUAGE DataKinds, GADTs #-} | |
module Zip where | |
import Data.Kind (Type) | |
data Zippy :: (k1 -> k2 -> Type) -> [k1] -> [k2] -> Type where | |
Nil :: Zippy f '[] '[] | |
(:~) :: f x y -> Zippy f xs ys -> Zippy f (x:xs) (y:ys) | |
newtype Fst a b = Fst{ getFst :: a } | |
newtype Snd a b = Snd{ getSnd :: b } | |
zipApply :: Zippy (->) xs ys -> Zippy Fst xs ys -> Zippy Snd xs ys | |
zipApply Nil Nil = Nil | |
zipApply (f :~ fs) (Fst x :~ xs) = Snd (f x) :~ zipApply fs xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment