Data.Dependent.Map examples

Viewed 406

Are there any examples anywhere of how to use the DMap type? The package documentation is very learned, and I know it if for reference only, but it is singularly unhelpful for one getting started. Google reveals nothing that I can see.

1 Answers

From the Updated README.md example pull request. One need to implement GEq and GCompare instances for a GADT:

data Foo a where
  AnInt   :: Foo Int
  AString :: Foo String

deriveGEq      ''Foo
deriveGCompare ''Foo

dmap1 :: DMap Foo Identity
dmap1 = fromList [AnInt ==> 1, AString ==> "bar"]

main = do
  print $ dmap1 ! AnInt
  print $ dmap1 ! AString
Related