Last active
August 29, 2015 13:56
-
-
Save reite/9096655 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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