Skip to content

Instantly share code, notes, and snippets.

@reite
Last active August 29, 2015 13:56
Show Gist options
  • Save reite/9096655 to your computer and use it in GitHub Desktop.
Save reite/9096655 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables #-}
data Foo a = Foo {
fooInt :: Int,
fooA :: a
}
-- Foo has its own indexes as well as all the indexes of a.
instance Indexable a => Indexable (Foo a) where
empty = [ ixFun (return . fooInt) ] ++ getIndexes (IX.empty :: IX.IxSet a)
where
getIndexes (IxSet xs) = map getIndex xs -- The IxSet constructor is not exported so this isnt possible.
getIndex (Ix _ f) = ixFun (f . fooA)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment