data-treify 0.3.1 → 0.3.2
raw patch · 5 files changed
+7/−89 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- CustomTy: (:*:) :: Ty a -> Ty b -> Ty (a, b)
- CustomTy: (:->:) :: Ty a -> Ty b -> Ty (a -> b)
- CustomTy: Bool :: Ty Bool
- CustomTy: Float :: Ty Float
- CustomTy: Integer :: Ty Integer
- CustomTy: class Typeable a
- CustomTy: data Ty a
- CustomTy: instance (Typeable a, Typeable b) => Typeable (a -> b)
- CustomTy: instance (Typeable a, Typeable b) => Typeable (a, b)
- CustomTy: instance IsTy Ty
- CustomTy: instance Typeable Bool
- CustomTy: instance Typeable Float
- CustomTy: instance Typeable Integer
- CustomTy: ty :: Typeable a => Ty a
- Exp: (:^) :: E v (a -> b) -> E v a -> E v b
- Exp: Add :: Op (a -> a -> a)
- Exp: App :: v (a -> b) -> v a -> N v b
- Exp: Let :: v a -> E v a -> E v b -> E v b
- Exp: Lit :: a -> Op a
- Exp: Mul :: Op (a -> a -> a)
- Exp: ON :: Op a -> N v a
- Exp: Op :: Op a -> E v a
- Exp: Var :: v a -> E v a
- Exp: bindsF :: [Bind Ty n] -> (V Ty a -> n (V Ty) a)
- Exp: bindsF' :: [Bind Ty N] -> (V Ty a -> N (V Ty) a)
- Exp: children :: N (V Ty) a -> [Id]
- Exp: childrenB :: Bind Ty N -> [Id]
- Exp: cse :: Typeable a => E (V Ty) a -> IO (E (V Ty) a)
- Exp: data E :: (* -> *) -> * -> *
- Exp: data N :: (* -> *) -> * -> *
- Exp: data Op :: * -> *
- Exp: histogram :: [Int] -> IntMap Int
- Exp: instance (Typeable a, Num a) => Num (E (V Ty) a)
- Exp: instance Eq (E v a)
- Exp: instance MuRef Ty (E v)
- Exp: instance Show (E (V Ty) a)
- Exp: instance Show (Op a)
- Exp: instance ShowF Op
- Exp: instance ShowF v => ShowF (N v)
- Exp: nodeE :: N v a -> E v a
- Exp: notSupp :: String -> a
- Exp: op2 :: (Typeable a, Typeable b, Typeable c) => Op (a -> b -> c) -> E v a -> E v b -> E v c
- Exp: parens :: String -> String
- Exp: reify :: (MuRef Ty h, Typeable a) => h a -> IO (Graph Ty (DeRef h) a)
- Exp: sqr :: Num a => a -> a
- Exp: ssa :: Typeable a => E (V Ty) a -> IO (E (V Ty) a)
- Exp: test :: Int -> E (V Ty) Integer
- Exp: unGraph :: Typeable a => Graph Ty N a -> E (V Ty) a
- Exp: unGraph2 :: Graph Ty N a -> E (V Ty) a
- Exp: uses :: [Bind Ty N] -> (Id -> Int)
- Data.TReify: class MuRef ty h where { type family DeRef h :: (* -> *) -> * -> *; }
+ Data.TReify: class MuRef ty h where type family DeRef h :: (* -> *) -> * -> *
Files
- Makefile +0/−1
- data-treify.cabal +3/−1
- src/Data/Junk.hs +0/−76
- src/Data/Reify/Junk.hs +0/−10
- src/Exp.hs +4/−1
− Makefile
@@ -1,1 +0,0 @@-include ../conal-cabal-make.inc
data-treify.cabal view
@@ -1,7 +1,8 @@ Name: data-treify-Version: 0.3.1+Version: 0.3.2 Synopsis: Reify a recursive data structure into an explicit graph. Description: This package is a (probably temporary) fork of Andy gill's data-reify package.+ I've tweaked it for typed syntax representations for use with GADTs. . 'data-reify' provided the ability to turn recursive structures into explicit graphs. Many (implicitly or explicitly) recursive data structure can be given this ability, via@@ -38,6 +39,7 @@ Exposed-modules: Data.TReify Data.Reify.TGraph+ Other-modules: CustomTy Exp Ghc-Options: -Wall
− src/Data/Junk.hs
@@ -1,76 +0,0 @@---- From TReify.hs, line 53, 06/05/2009 12:44:32 PM:--data Bind n where- Bind :: V a -> n V a -> Bind n---- From TReify.hs, line 45, 06/05/2009 12:48:14 PM:---- Hm. How to get Graph and reifyGraph not have to know about Ty and--- tyEq? I'd rather not build in that dependency, since Ty isn't--- universal. It handles some types and not others. Is there a way to--- fix Ty? Perhaps an unsafeCoerce hack. Done! Now Ty uses TypeRef and--- an unsafeCoerce.---- From TReify.hs, line 84, 06/05/2009 01:40:29 PM:--mylookup' st tab =- do tab2 <- M.lookup (hashStableName st) tab- Prelude.lookup st tab2---- From TReify.hs, line 62, 06/05/2009 05:22:13 PM:---- TODO: Move the following defs to TGraph.hs--type Id = Int--data V a = V Id (Ty a)---- data Shield2 f g = forall a. Shield2 (f a) (g a)---- type Bind n = Shield V (n V)--data Bind n = forall a. Bind (V a) (n V a)--data Graph n a = Graph [Bind n] (V a)---- From TReify.hs, line 23, 06/05/2009 05:25:54 PM:---- import Data.Reify.TGraph---- | 'MuRef' is a class that provided a way to reference into a specific type,--- and a way to map over the deferenced internals.---- class MuRef a where--- type DeRef a :: * -> *---- mapDeRef :: (Applicative m) --- => (a -> m u)--- -> (a -> m (DeRef a u)---- -- specialized for use here:--- mapDeRef :: (a -> IO Int )--- -> (a -> IO (DeRef a Int))----- From Ty.hs, line 37, 06/07/2009 04:36:31 PM:---tyEq :: Ty a -> Ty b -> Maybe (a :=: b)-Ty a `tyEq` Ty b | a == b = unsafeCoerce (Just Refl)- | otherwise = Nothing--ty :: Typeable a => Ty a-ty = tyOf (undefined :: a)--tyOf :: Typeable a => a -> Ty a-tyOf a = Ty (typeOf a)---- From Ty.hs, line 36, 06/07/2009 04:37:13 PM:--tyEq :: Ty a -> Ty b -> Maybe (a :=: b)-Ty a `tyEq` Ty b | a == b = unsafeCoerce (Just Refl)- | otherwise = Nothing--ty :: Typeable a => Ty a-ty = tyOf (undefined :: a)
− src/Data/Reify/Junk.hs
@@ -1,10 +0,0 @@---- From TGraph.hs, line 14, 06/05/2009 05:19:00 PM:---- | Typed binding pair, parameterized by variable and node type--- constructors. -data Bind n v where- Bind :: v a -> n v a -> Bind n v---- | Graph, described by bindings and a root variable-data Graph n v a = Graph [Bind n v] (v a)
src/Exp.hs view
@@ -4,6 +4,9 @@ #-} {-# OPTIONS_GHC -Wall -fno-warn-missing-methods -fno-warn-missing-signatures #-} +-- Example of data-treify for a first pass of CSE on a simple typed+-- language representation.+ module Exp where import Control.Applicative (pure,(<$>),(<*>))@@ -193,7 +196,7 @@ instance Eq (E v a) -instance (Typeable a, Num a) => Num (E (V Ty) a) where+instance (Typeable a, Show a, Num a) => Num (E (V Ty) a) where fromInteger x = Op (Lit (fromInteger x)) (+) = op2 Add (*) = op2 Mul