Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.md example with a currently working one. #16

Closed
wants to merge 2 commits into from

Conversation

JavierJF
Copy link

@JavierJF JavierJF commented Apr 21, 2017

Fixes #15 .

@chshersh
Copy link

chshersh commented Feb 8, 2018

Any news on merging this to master or/and resolving conflicts? I would love to use dependent-map package but I find lack of documentation frustrating...

@JavierJF JavierJF mentioned this pull request Mar 1, 2018
@ryantrinkle
Copy link
Member

@JavierJF Would you mind updating this so that it merges cleanly against the current master?

@JavierJF
Copy link
Author

JavierJF commented Mar 1, 2018

Of course, I will update it soon. Thanks you.

@Wizek
Copy link

Wizek commented Apr 24, 2018

Any updates on this? I'm also trying to try this package without much success yet.

Also, where can I find the FooGADT module? Shouldn't its content be inlined into the readme for a self-contained example?

cc @JavierJF

@Wizek Wizek mentioned this pull request Apr 24, 2018
@Wizek
Copy link

Wizek commented Apr 25, 2018

Together with @vaibhavsagar, earlier today we were able to make some sense of this package. Here is a small, self-contained, compiling (as of latest, 0.2.4.0) example that we got to:

{-# language GADTs #-}
{-# language DeriveGeneric #-}
{-# language DeriveAnyClass #-}
{-# language TemplateHaskell #-}
{-# language StandaloneDeriving #-}

import Prelude                  (Int, String, print, ($))
import Data.GADT.Show           ()
import Data.GADT.Compare        ()
import Data.Dependent.Map       (DMap, fromList, (!))
import Data.Dependent.Sum       ((==>))
import Data.GADT.Compare.TH     (deriveGEq, deriveGCompare)
import Data.Functor.Identity    (Identity)

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

  -- Prints:
  -- Identity 1
  -- Identity "bar"

It might make sense to put this into the readme and/or hackage/haddocs.

(Showability (e.g. print $ fromList [AnInt ==> 1]) is still a mystery to us.)

Edit: Included explicit imports to further improve understandability.

@3noch
Copy link
Collaborator

3noch commented Apr 2, 2020

I've updated the README to a working example.

@3noch 3noch closed this Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example code from README.md doesn't compile
5 participants