Created
September 24, 2019 20:03
-
-
Save masaeedu/a2e58e1aa350d139ea97a03fbb3fdbda to your computer and use it in GitHub Desktop.
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, RankNTypes, TypeOperators #-} | |
module Traversals where | |
import Control.Monad.Free | |
type (~>) f g = forall x. f x -> g x | |
data Nat = Z | S Nat | |
data HVec n f a | |
where | |
HNil :: a -> HVec Z f a | |
HCons :: f (HVec n f a) -> HVec (S n) f a | |
data HFunList a b t x | |
where | |
HFunList :: HVec n a x -> (HVec n b x -> t x) -> HFunList a b t x | |
type HTraversal s t a b = s ~> HFunList a b t | |
test :: (Functor a, Functor b) => HTraversal (Free a) (Free b) a b | |
test (Pure a) = HFunList (HNil a) (\(HNil b) -> Pure b) | |
test (Free ar) = HFunList (HCons (_ <$> ar)) (\(HCons br) -> Free (_ <$> br)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment