Skip to content

Instantly share code, notes, and snippets.

@kosmikus
Last active February 1, 2017 09:36
Show Gist options
  • Save kosmikus/68fd4a4cb1f7b15d91310c7367b2d297 to your computer and use it in GitHub Desktop.
Save kosmikus/68fd4a4cb1f7b15d91310c7367b2d297 to your computer and use it in GitHub Desktop.
{-# LANGUAGE AllowAmbiguousTypes, ConstraintKinds, RankNTypes, ScopedTypeVariables #-}
module CompTest where
import Generics.SOP
import Generics.SOP.Constraint
-- hcmap :: (HAp h, AllN (Prod h) c xs) => proxy c -> (forall a . c a => f a -> f' a) -> h f xs -> h f' xs
-- hcollapse :: (HCollapse h, SListIN h xs) => h (K a) xs -> CollapseTo h a
hcmapQ ::
forall h c b xs proxy .
(HAp h, AllN (Prod h) c xs, HCollapse h, SListIN h xs)
=> proxy c -> (forall a . c a => a -> b) -> h I xs -> CollapseTo h b
hcmapQ p f x = hcollapse (hcmap p g x :: h (K b) xs)
where
g :: forall a xs . c a => I a -> K b a
g = K . f . unI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment