Skip to content

Instantly share code, notes, and snippets.

@Sophia-Gold
Created April 6, 2018 09:56
Show Gist options
  • Select an option

  • Save Sophia-Gold/9451771ab8a809d4eb131c5c53668aa3 to your computer and use it in GitHub Desktop.

Select an option

Save Sophia-Gold/9451771ab8a809d4eb131c5c53668aa3 to your computer and use it in GitHub Desktop.
type level iterate
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
data Nat = Z | S Nat
type family Iterate (n :: Nat) f a where
Iterate Z f a = a
Iterate (S n) f a = f (Iterate n f a)
thing :: Iterate (S (S (S Z))) [] Int
thing = [[[3,4],[2]],[[],[9,9,9]],[]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment