data-reify-gadt 0.1.0.0 → 0.1.0.1
raw patch · 5 files changed
+108/−97 lines, 5 filesdep ~containersdep ~hashabledep ~hspecPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: containers, hashable, hspec, unordered-containers
API changes (from Hackage documentation)
- Data.Reify.GADT: type E (a :: Type -> Type) :: Type -> Type;
+ Data.Reify.GADT: type SubNode (a :: Type -> Type) :: Type -> Type;
- Data.Reify.GADT: mapDeRef :: (MuRef a, Applicative f, e ~ E a) => (forall t'. MuRef e => e t' -> f (u t')) -> a t -> f (DeRef a u t)
+ Data.Reify.GADT: mapDeRef :: (MuRef a, Applicative f, e ~ SubNode a) => (forall t'. MuRef e => e t' -> f (u t')) -> a t -> f (DeRef a u t)
- Data.Reify.GADT: reifyGraph :: (MuRef s, E (E s) ~ E s, DeRef (E s) ~ DeRef s) => s a -> IO (Graph (DeRef s) a)
+ Data.Reify.GADT: reifyGraph :: (MuRef s, SubNode (SubNode s) ~ SubNode s, DeRef (SubNode s) ~ DeRef s) => s a -> IO (Graph (DeRef s) a)
- Data.Reify.GADT: reifyGraphs :: (MuRef s, E (E s) ~ E s, DeRef (E s) ~ DeRef s, Traversable t) => t (s e) -> IO (t (Graph (DeRef s) e))
+ Data.Reify.GADT: reifyGraphs :: (MuRef s, SubNode (SubNode s) ~ SubNode s, DeRef (SubNode s) ~ DeRef s, Traversable t) => t (s e) -> IO (t (Graph (DeRef s) e))
Files
- README.md +6/−1
- data-reify-gadt.cabal +94/−87
- examples/ast.hs +1/−1
- src/Data/Reify/GADT.hs +6/−7
- test/Spec.hs +1/−1
README.md view
@@ -1,8 +1,13 @@ # `Data.Reify.GADT` +[](https://hackage.haskell.org/package/data-reify-gadt)+[](https://hackage.haskell.org/package/data-reify-gadt-0.1.0.0/docs/Data-Reify-GADT.html)+[](https://github.com/Arthi-chaud/data-reify-gadt/actions/workflows/CI.yml)++ `data-reify-gadt` is a rewrite of [`data-reify`](https://hackage.haskell.org/package/data-reify) to make the library usable with GADTs. -With this implementation, it is possible to use `data-reify`'s technique to make a graph out of typed ASTs that uses GADTs.+With this implementation, it is possible to use `data-reify`'s technique to make a graph out of typed ASTs that use GADTs. The logic is the same, only the type definition changes slightly.
data-reify-gadt.cabal view
@@ -1,96 +1,103 @@-cabal-version: 2.2-name: data-reify-gadt-version: 0.1.0.0-license: BSD-3-Clause-license-file: LICENSE-copyright: 2025 Arthur Jamet-maintainer: aj530@kent.ac.uk-author: Arthur Jamet-tested-with: ghc ==9.6.6 ghc ==9.8.4 ghc ==9.10.1 ghc ==9.12.1-homepage: https://github.com/Arthi-chaud/data-reify-gadt#readme-bug-reports: https://github.com/Arthi-chaud/data-reify-gadt/issues-synopsis: Data.Reify for GADTs-description:- Please see the README on GitHub at <https://github.com/Arthi-chaud/data-reify-gadt#readme>+cabal-version: 2.2 -category: Data-build-type: Simple-extra-source-files: README.md+-- This file has been generated from package.yaml by hpack version 0.37.0.+--+-- see: https://github.com/sol/hpack +name: data-reify-gadt+version: 0.1.0.1+synopsis: Data.Reify for GADTs+description: Please see the README on GitHub at <https://github.com/Arthi-chaud/data-reify-gadt#readme>+category: Data+homepage: https://github.com/Arthi-chaud/data-reify-gadt#readme+bug-reports: https://github.com/Arthi-chaud/data-reify-gadt/issues+author: Arthur Jamet+maintainer: aj530@kent.ac.uk+copyright: 2025 Arthur Jamet+license: BSD-3-Clause+license-file: LICENSE+build-type: Simple+tested-with:+ GHC ==9.6.6+ , GHC ==9.8.4+ , GHC ==9.10.1+ , GHC ==9.12.1+extra-source-files:+ README.md+ source-repository head- type: git- location: https://github.com/Arthi-chaud/data-reify-gadt+ type: git+ location: https://github.com/Arthi-chaud/data-reify-gadt library- exposed-modules:- Data.Reify.GADT- Data.Reify.GADT.Graph-- hs-source-dirs: src- other-modules:- Lib- Paths_data_reify_gadt-- autogen-modules: Paths_data_reify_gadt- default-language: Haskell2010- default-extensions:- RankNTypes QuantifiedConstraints UndecidableInstances- ExistentialQuantification TypeOperators-- ghc-options:- -Wall -Wcompat -Widentities -Wincomplete-record-updates- -Wincomplete-uni-patterns -Wmissing-export-lists- -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints-- build-depends:- base >=4.7 && <5,- containers >=0.7 && <0.8,- hashable >=1.5.0.0 && <1.6,- unordered-containers >=0.2.20 && <0.3+ exposed-modules:+ Data.Reify.GADT+ Data.Reify.GADT.Graph+ other-modules:+ Lib+ Paths_data_reify_gadt+ autogen-modules:+ Paths_data_reify_gadt+ hs-source-dirs:+ src+ default-extensions:+ RankNTypes+ QuantifiedConstraints+ UndecidableInstances+ ExistentialQuantification+ TypeOperators+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints+ build-depends:+ base >=4.7 && <5+ , containers+ , hashable+ , unordered-containers+ default-language: Haskell2010 executable example-ast- main-is: ast.hs- hs-source-dirs: examples- other-modules: Paths_data_reify_gadt- autogen-modules: Paths_data_reify_gadt- default-language: Haskell2010- default-extensions:- RankNTypes QuantifiedConstraints UndecidableInstances- ExistentialQuantification TypeOperators-- ghc-options:- -Wall -Wcompat -Widentities -Wincomplete-record-updates- -Wincomplete-uni-patterns -Wmissing-export-lists- -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints-- build-depends:- base >=4.7 && <5,- containers >=0.7 && <0.8,- data-reify-gadt,- hashable >=1.5.0.0 && <1.6,- unordered-containers >=0.2.20 && <0.3+ main-is: ast.hs+ other-modules:+ Paths_data_reify_gadt+ autogen-modules:+ Paths_data_reify_gadt+ hs-source-dirs:+ examples+ default-extensions:+ RankNTypes+ QuantifiedConstraints+ UndecidableInstances+ ExistentialQuantification+ TypeOperators+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints+ build-depends:+ base >=4.7 && <5+ , containers+ , data-reify-gadt+ , hashable+ , unordered-containers+ default-language: Haskell2010 test-suite test- type: exitcode-stdio-1.0- main-is: Spec.hs- hs-source-dirs: test- other-modules: Paths_data_reify_gadt- autogen-modules: Paths_data_reify_gadt- default-language: Haskell2010- default-extensions:- RankNTypes QuantifiedConstraints UndecidableInstances- ExistentialQuantification TypeOperators-- ghc-options:- -Wall -Wcompat -Widentities -Wincomplete-record-updates- -Wincomplete-uni-patterns -Wmissing-export-lists- -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints- -threaded -rtsopts -with-rtsopts=-N-- build-depends:- base >=4.7 && <5,- containers >=0.7 && <0.8,- data-reify-gadt,- hashable >=1.5.0.0 && <1.6,- hspec >=2.11.11 && <2.12,- unordered-containers >=0.2.20 && <0.3+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ other-modules:+ Paths_data_reify_gadt+ autogen-modules:+ Paths_data_reify_gadt+ hs-source-dirs:+ test+ default-extensions:+ RankNTypes+ QuantifiedConstraints+ UndecidableInstances+ ExistentialQuantification+ TypeOperators+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base >=4.7 && <5+ , containers+ , data-reify-gadt+ , hashable+ , hspec+ , unordered-containers+ default-language: Haskell2010
examples/ast.hs view
@@ -20,7 +20,7 @@ instance MuRef (Fix TreeF) where type DeRef (Fix TreeF) = TreeF- type E (Fix TreeF) = Fix TreeF+ type SubNode (Fix TreeF) = Fix TreeF mapDeRef f (Fx e) = case e of Leaf a -> pure $ Leaf a Node l r -> Node <$> f l <*> f r
src/Data/Reify/GADT.hs view
@@ -27,9 +27,9 @@ -- and a way to map over the deferenced internals. class MuRef (a :: Type -> Type) where type DeRef a :: (Type -> Type) -> (Type -> Type)- type E a :: Type -> Type+ type SubNode a :: Type -> Type mapDeRef ::- (Applicative f, e ~ E a) =>+ (Applicative f, e ~ SubNode a) => (forall t'. (MuRef e) => e t' -> f (u t')) -> a t -> f ((DeRef a) u t)@@ -37,7 +37,7 @@ -- | 'reifyGraph' takes a data structure that admits 'MuRef', and returns a 'Graph' that contains -- the dereferenced nodes, with their children as 'Unique's rather than recursive values. reifyGraph ::- (MuRef s, E (E s) ~ E s, DeRef (E s) ~ DeRef s) =>+ (MuRef s, SubNode (SubNode s) ~ SubNode s, DeRef (SubNode s) ~ DeRef s) => s a -> IO (Graph (DeRef s) a) reifyGraph m = do@@ -51,7 +51,7 @@ -- -- This allows for, e.g., a list of mutually recursive structures. reifyGraphs ::- (MuRef s, E (E s) ~ E s, DeRef (E s) ~ DeRef s, Traversable t) =>+ (MuRef s, SubNode (SubNode s) ~ SubNode s, DeRef (SubNode s) ~ DeRef s, Traversable t) => t (s e) -> IO (t (Graph (DeRef s) e)) reifyGraphs coll = do@@ -67,7 +67,7 @@ -- Reify a data structure's 'Graph' using the supplied map of stable names and -- unique supply. reifyWithContext ::- (MuRef s, E (E s) ~ E s, DeRef (E s) ~ DeRef s) =>+ (MuRef s, SubNode (SubNode s) ~ SubNode s, DeRef (SubNode s) ~ DeRef s) => MVar (HashMap DynStableName Unique) -> MVar Unique -> s a ->@@ -81,8 +81,7 @@ -- The workhorse for 'reifyGraph' and 'reifyGraphs'. findNodes ::- -- ‘DeRef (E (e t) t') ~ DeRef (e t')’- (MuRef s, E (E s) ~ E s, DeRef (E s) ~ DeRef s) =>+ (MuRef s, SubNode (SubNode s) ~ SubNode s, DeRef (SubNode s) ~ DeRef s) => -- | A map of stable names to unique numbers. -- Invariant: all 'Uniques' that appear in the range are less -- than the current value in the unique name supply.
test/Spec.hs view
@@ -18,7 +18,7 @@ instance MuRef (Fix ExprF) where type DeRef (Fix ExprF) = ExprF- type E (Fix ExprF) = Fix ExprF+ type SubNode (Fix ExprF) = Fix ExprF mapDeRef f (Fx e) = case e of Val a -> pure $ Val a Dup a -> Dup <$> f a