sai-shape-syb 0.2.1 → 0.2.2
raw patch · 6 files changed
+41/−144 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- HTML/ghc.html +21/−24
- HTML/sai-shape-syb.html +11/−112
- sai-shape-syb.cabal +1/−1
- src/SAI/Data/Generics/Shape.hs +4/−4
- src/SAI/Data/Generics/Shape/SYB.hs +2/−1
- src/SAI/Data/Generics/Shape/SYB/GHC.hs +2/−2
HTML/ghc.html view
@@ -10,13 +10,14 @@ <h2>Dealing with GHC Staging Holes</h2> GHC AST has some funny types which "blow up" if you examine them.-SYB works by attempting <tt>unsafeCoerce</tt>'s, which triggers these holes.+SYB works by attempting type-safe cast, which triggers these holes. We need a "staged" version of <tt>ghom</tt> (at least). The HaRe source contains a good model of this (its GhcUtils.hs module). Using that I made <tt>ghomStaged</tt> <pre> + -- (Note: this is now ghomStagedK in the API.) ghomStaged :: forall r d. Data d => SYB.Stage -> r@@ -35,7 +36,7 @@ </pre> <tt>checkItemStage</tt> is from HaRe and can be found in the-<a href="sai-shape-syb-0.2.0.tar.gz">download</a>.+<a href="sai-shape-syb-0.2.2.tar.gz">download</a>. <br> Note also you will need to have <a href="http://hackage.haskell.org/package/ghc-syb-utils">ghc-syb-utils</a> installed for these experiments. @@ -63,28 +64,24 @@ liftIO $ putStrLn $ showAsParens $ shapeOfStaged typechecked -(((()((()(()(()())))(()(()(()())))((()()(((((())((())(())))((())((())(()))))(-()))(((((()))((())))((())))((((()))((())))((())))))(()))())()(((()((()())()((-(()(((()(()))((()(((()(()))((()(()))()))()(()((())((())())))))()))()(((()((((-)((()((()((((()))((())))(())))(()(()))))((()))((()))(()())))())(()((((()(()))-)(((()((()(()))(()((((()))((())))(())))(()())(()(((())()((()((((()))((())))((-))))(()((()(()())))))(())))))))()))()))))((()(((()((()(()))((()))((()))(()())-))())(()((((()((()(()))(()((((()))((())))(())))(()())(()(((())()((()((((()))(-(())))(())))(()((()(()())))))(())))))))(((()(())))()))()))))()))())))())((())-((()((())((())())))(()((())((())()))))))()()()))()))))((()((()(()(()())))(()(-()(()())))((()()(((((())((())(())))((())((())(()))))(()))(((((()))((())))((()-)))((((()))((())))((())))))(()))())()(((()((()())()(((()(((()((()())()()()(()-)(()((())()))))((()(()))()))()(((()(()(()(()))))())())))((()(((()((()((()())(-)()()((()(()))(()(())))(()((())()))))))((()(()))()))()(((()(()(()((()((()(())-)(()(()))))(()((()((()((()((((((()))((())))((())))((((()))((())))((()))))(())-))(()(()))))(()(()))))))))))())())))()))((()((())()))((()((())((())())))(()((-())((())()))))))()()()))()))))((()(()()((()()()(()))())()(((()((()())()(((()(-()()(((()(()(()((()(((()((()())((()())()))))(())))(()((()((()((()((((((()))((-())))((())))((((()()))((()())))((()()))))(())))(()(((((()))((()())))(()))((()-(((())()((()((((()))((()())))(())))(()((()(()())))))(()()))))(()(((())()((()(-(((()))((()())))(())))(()((()(()())))))(()())))))))))(()((((()((()(((())()(((-)))(()()))))(()(())))))(((()((()(((())()((()))(()()))))(()(())))))()))())))))-)))))())())))())(()((()((()())((()())())))())))()()()))()))))()))))+(((*((*(*(**)))(*(*(**)))((**(((((*)((*)(*)))((*)((*)(*))))(*))(((((*))((*)))+((*)))((((*))((*)))((*)))))(*))*)*(((*((**)*(((*(((*(*))((*(((*(*))((*(*))*))+*(*((*)((*)*)))))*))*(((*(((*((*((*((((*))((*)))(*)))(*(*))))((*))((*))(**)))+*)(*((((*(*)))(((*((*(*))(*((((*))((*)))(*)))(**)(*(((*)*((*((((*))((*)))(*))+)(*((*(**)))))(*)))))))*))*))))((*(((*((*(*))((*))((*))(**)))*)(*((((*((*(*))+(*((((*))((*)))(*)))(**)(*(((*)*((*((((*))((*)))(*)))(*((*(**)))))(*)))))))((+(*(*)))*))*))))*))*)))*)((*)((*((*)((*)*)))(*((*)((*)*))))))***))*))))((*((*(+*(**)))(*(*(**)))((**(((((*)((*)(*)))((*)((*)(*))))(*))(((((*))((*)))((*)))((+((*))((*)))((*)))))(*))*)*(((*((**)*(((*(((*((**)***(*)(*((*)*))))((*(*))*))*+(((*(*(*(*))))*)*)))((*(((*((*((**)***((*(*))(*(*)))(*((*)*))))))((*(*))*))*(+((*(*(*((*((*(*))(*(*))))(*((*((*((*((((((*))((*)))((*)))((((*))((*)))((*))))+(*)))(*(*))))(*(*))))))))))*)*)))*))((*((*)*))((*((*)((*)*)))(*((*)((*)*)))))+)***))*))))((*(**((***(*))*)*(((*((**)*(((*(**(((*(*(*((*(((*((**)((**)*))))(+*)))(*((*((*((*((((((*))((*)))((*)))((((**))((**)))((**))))(*)))(*(((((*))((*+*)))(*))((*(((*)*((*((((*))((**)))(*)))(*((*(**)))))(**))))(*(((*)*((*((((*))+((**)))(*)))(*((*(**)))))(**)))))))))(*((((*((*(((*)*((*))(**))))(*(*)))))(((+*((*(((*)*((*))(**))))(*(*)))))*))*))))))))))*)*)))*)(*((*((**)((**)*)))*)))*+**))*))))*)))) </pre>
HTML/sai-shape-syb.html view
@@ -8,13 +8,13 @@ <h2>Download</h2> -Here's <a href="sai-shape-syb-0.2.0.tar.gz">full source</a> (BSD3-licensed, Cabal sdist) for:+Here's <a href="sai-shape-syb-0.2.2.tar.gz">full source</a> (BSD3-licensed, Cabal sdist) for: <ul> <li>building the library (providing <tt>Data.Generics.Shape.{SYB, SYB.Filter, SYB.GHC}</tt>), and <li>building the testbench corresponding to the examples in this post. </ul> -Haddock API <a href="api/html/sai-shape-syb/index.html">here</a>.+<p> On Hackage: <a href="http://hackage.haskell.org/package/sai-shape-syb">sai-shape-syb</a> @@ -80,7 +80,7 @@ <p> This package supports a generic mapping which works over arbitrary recursive heterogeneous types.-It differs from existing generic fmap (SYB's gmapT, or Oleg's <a href="http://marc.info/?l=haskell-generics&m=121665568609280">gmap</a>), in that it allows you to obtain a homogeneous result in the type of your choice, rather than adhering to the original types.+It differs from existing generic fmap (SYB's gmapT, or Oleg's <a href="http://marc.info/?l=haskell-generics&m=121665568609280">gmap</a>), in that it allows you to obtain a homogeneous result in the type of your choice, rather than adhering to the original types. [Actually maybe Oleg's will do this.] Hence, this is not an <tt>fmap</tt>, it doesn't satisfy the laws. (It's a homomorphism.) It uses gfoldl, so fold-as-map.@@ -147,20 +147,20 @@ data TA = A1 | A2 TB TA TB data TB = B TA exprAB = A2 (B A1) A1 (B A1)--- ((())()(()))+-- ((*)*(*)) data TC = C1 Float (Int,Int) | C2 TD TC TD | C3 TC data TD = D TC exprCD = C2 (D (C1 1.1 (4,5))) (C3 (C1 2.2 (6,7))) (D (C1 3.3 (8,9)))--- (((()(()())))((()(()())))((()(()()))))+-- (((*(**)))((*(**)))((*(**)))) data TE = E1 String | E2 (Int,Int) TF data TF = F TE String exprEF = E2 (2,5) (F (E1 "foo") "bar")--- ((()(())())()()) -- with [Char] as a stop type, so String is treated as atomic+-- ((*(*)*)**) -- with [Char] as a stop type, so String is treated as atomic test_list = [[1,2],[3],[4,5,6::Int]]--- ((()(()()))((()())((()(()(()())))())))+-- ((*(**))((**)((*(*(**)))*))) ----------------------------------------------- @@ -188,7 +188,7 @@ > showAsParens $ shapeOf test_list -((()(()()))((()())((()(()(()())))())))+((*(**))((**)((*(*(**)))*))) > showAsParensBool $ ghom (mkQ False (odd::Int->Bool)) test_list @@ -358,15 +358,15 @@ > showAsParens $ shapeOf exprAB -((())()(()))+((*)*(*)) > showAsParens $ shapeOf exprCD -(((()(()())))((()(()())))((()(()()))))+(((*(**)))((*(**)))((*(**)))) > showAsParens $ shapeOf exprEF -((()())(((()(()(()()))))(()(()(()())))))+((**)(((*(*(**))))(*(*(**))))) > show $ ( ( unGhomDyn $ ghomDyn exprEF ) :: TE ) @@ -565,107 +565,6 @@ ([[3],[4,5,6]], Nothing) (3, Just 3) (5, Just 5)---Testing abstract datatype:--> show exprN--fromList [("",1.1),("pdsfhp",3.3),("sfv",2.2)]--> show $ Map.toList exprN--[("",1.1),("pdsfhp",3.3),("sfv",2.2)]--> showHomo $ shapeOf exprN--()-| ()-| | ()-| | | ()-| | | ()-| | ()-| | | ()-| | | | ()-| | | | | ()-| | | | | ()-| | | | | | ()-| | | | | | ()-| | | | | | | ()-| | | | | | | ()-| | | | | | | | ()-| | | | | | | | ()-| | | | | | | | | ()-| | | | | | | | | ()-| | | | | | | | | | ()-| | | | | | | | | | ()-| | | | ()-| | | ()-| | | | ()-| | | | | ()-| | | | | | ()-| | | | | | ()-| | | | | | | ()-| | | | | | | ()-| | | | | | | | ()-| | | | | | | | ()-| | | | | ()-| | | | ()--> showAsParensEnriched $ shapeOf exprN--(()(()(()(())(()))(()(()(()(())(()(())(()(())(()(())(()(())(()(())(())))))))(()))(()(()(()(())(()(())(()(())(()))))(()))(())))))--> showHomo $ ghom (mkQ 0.0 (\ (x::Float) -> x)) exprN--0.0-| 0.0-| | 0.0-| | | 0.0-| | | 1.1-| | 0.0-| | | 0.0-| | | | 0.0-| | | | | 0.0-| | | | | 0.0-| | | | | | 0.0-| | | | | | 0.0-| | | | | | | 0.0-| | | | | | | 0.0-| | | | | | | | 0.0-| | | | | | | | 0.0-| | | | | | | | | 0.0-| | | | | | | | | 0.0-| | | | | | | | | | 0.0-| | | | | | | | | | 0.0-| | | | 3.3-| | | 0.0-| | | | 0.0-| | | | | 0.0-| | | | | | 0.0-| | | | | | 0.0-| | | | | | | 0.0-| | | | | | | 0.0-| | | | | | | | 0.0-| | | | | | | | 0.0-| | | | | 2.2-| | | | 0.0--> showHomo $ filterHomo (>0.5) $ ghom (mkQ 0.0 (\ (x::Float) -> x)) exprN--0.0-| 1.1-| 3.3-| 2.2--> showHomo $ filterHomoM (>0.5) $ ghom (mkQ 0.0 (\ (x::Float) -> x)) exprN--Nothing-| Nothing-| | Just 1.1-| | Nothing-| | | Just 3.3-| | | Just 2.2 </pre>
sai-shape-syb.cabal view
@@ -1,6 +1,6 @@ name: sai-shape-syb-version: 0.2.1+version: 0.2.2 synopsis: Obtain homogeneous values from arbitrary values, tramsforming or culling data description: This package provides SYB shape support: generic mapping to
src/SAI/Data/Generics/Shape.hs view
@@ -22,9 +22,6 @@ module SAI.Data.Generics.Shape ( - --- * Core SYB exports---module SAI.Data.Generics ,- -- * Generic shape module SAI.Data.Generics.Shape.SYB , @@ -34,11 +31,14 @@ -- * Generic shape, variants for handling GHC API staged types module SAI.Data.Generics.Shape.SYB.GHC , + --- * Core SYB exports (user will need mkQ at least)+ module Data.Generics ,+ ) where ------------------------------------------------------------------------------ ---import Data.Generics+import Data.Generics import SAI.Data.Generics.Shape.SYB --import SAI.Data.Generics.Shape.SYB hiding ( R )
src/SAI/Data/Generics/Shape/SYB.hs view
@@ -400,7 +400,7 @@ ------------------------------------------------------------------------------- - -- | Compare two rose trees for shape equality.+ -- | Compare two general polytypic values for shape equality. symmorphic :: forall d1 d2. (Data d1,Data d2) => d1 -> d2 -> Bool #if 1 symmorphic x y = shapeOf x == shapeOf y@@ -555,6 +555,7 @@ ------------------------------------------------------------------------------- showAsParens :: Homo r -> String+ showAsParens (Node _ []) = "*" showAsParens (Node _ chs) = "(" ++ concatMap showAsParens chs ++ ")" showAsParensBool :: Homo Bool -> String
src/SAI/Data/Generics/Shape/SYB/GHC.hs view
@@ -26,7 +26,7 @@ -- for more information. -- -- The present module provides support for staged GHC AST types.--- One you have a @'Homo' r@, 'Hetero', or @'Bi' r@, the rest of+-- Once you have a @'Homo' r@, 'Hetero', or @'Bi' r@, the rest of -- the API in "Shape.SYB" and "Shape.SYB.Filter" is applicable. -- -----------------------------------------------------------------------------@@ -195,7 +195,7 @@ ------------------------------------------------------------------------------- - -- | Compare two rose trees for shape equality.+ -- | Compare two GHC ASTs for shape equality. symmorphicStaged :: forall d1 d2. (Data d1,Data d2) => Stage -> d1 -> d2 -> Bool symmorphicStaged stage x y = shapeOfStaged stage x == shapeOfStaged stage y