Skip to content

Instantly share code, notes, and snippets.

@supki
Last active December 16, 2015 05:59
Show Gist options
  • Save supki/5388106 to your computer and use it in GitHub Desktop.
Save supki/5388106 to your computer and use it in GitHub Desktop.
M
instance (Enum a, Num a) => Num [a] where
(*) = liftA2 (*)
fromInteger n = [1..fromInteger n]
instance (Enum a, Real a) => Real [a] where
instance Enum [a] where
instance Integral a => Integral [a] where
mod = liftA2 mod
instance (Applicative m, Integral (m a), Reifies s a) => Num (TaggedT s m a) where
TaggedT x * TaggedT y = mapTaggedT ((x * y) `mod`) reflexivity
fromInteger = tag . fromInteger
-- >>> weirdo 11 (4 × 7)
-- [1,2,3,4,5,6,7,2,4,6,8,10,1,3,3,6,9,1,4,7,10,4,8,1,5,9,2,6]
weirdo :: Int -> (forall s. Reifies s Int => TaggedT s [] Int) -> [Int]
weirdo n z = reify n (untag . asProxyOf z)
asProxyOf :: p s m a -> Proxy s -> p s m a
asProxyOf a _ = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment