Skip to content

Instantly share code, notes, and snippets.

@NathanHowell
Created October 8, 2013 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanHowell/6880968 to your computer and use it in GitHub Desktop.
Save NathanHowell/6880968 to your computer and use it in GitHub Desktop.
Convert a type to a nested tuple, preserving left-to-right ordering via CPS conversion.
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Typeable
convert :: (Typeable t, Typeable b) => (forall a . Typeable a => a -> r) -> [t] -> b -> r
convert f (x:xs) b = convert f xs (x, b)
convert f [] b = f b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment