From 08ef0e26dccb2cb3ac2dce4557642a305014bae6 Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Sun, 4 Mar 2018 15:51:46 -0800 Subject: [PATCH] Derive Show instances for route data structures * It's very helpful to have a Show instance for debugging and development * Currently third party packages are deriving this instance themselves which is not ideal. * http://hackage.haskell.org/package/yesod-routes-flow-2.0/docs/src/Yesod-Routes-Flow-Generator.html * http://hackage.haskell.org/package/yesod-routes-typescript-0.3.0.0/docs/src/Yesod-Routes-Typescript-Generator.html * This change would break those packages, which isn't great * At least the typescript one is broken anyway --- yesod-core/ChangeLog.md | 5 +++++ yesod-core/Yesod/Routes/TH/Types.hs | 4 ++-- yesod-core/yesod-core.cabal | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/yesod-core/ChangeLog.md b/yesod-core/ChangeLog.md index 8234e978..443649a7 100644 --- a/yesod-core/ChangeLog.md +++ b/yesod-core/ChangeLog.md @@ -1,3 +1,8 @@ +## 1.6.2 + +* Derive a `Show` instance for `ResourceTree` and `FlatResource` [#1492](https://github.com/yesodweb/yesod/pull/1492) + * Some third party packages, like `yesod-routes-flow` derive their own `Show` instance, and this will break those packages. + ## 1.6.1 * Add a `Semigroup LiteApp` instance, and explicitly define `(<>)` in the diff --git a/yesod-core/Yesod/Routes/TH/Types.hs b/yesod-core/Yesod/Routes/TH/Types.hs index 369598e6..eeb70bbd 100644 --- a/yesod-core/Yesod/Routes/TH/Types.hs +++ b/yesod-core/Yesod/Routes/TH/Types.hs @@ -21,7 +21,7 @@ import Language.Haskell.TH.Syntax data ResourceTree typ = ResourceLeaf (Resource typ) | ResourceParent String CheckOverlap [Piece typ] [ResourceTree typ] - deriving Functor + deriving (Show, Functor) resourceTreePieces :: ResourceTree typ -> [Piece typ] resourceTreePieces (ResourceLeaf r) = resourcePieces r @@ -90,7 +90,7 @@ data FlatResource a = FlatResource , frPieces :: [Piece a] , frDispatch :: Dispatch a , frCheck :: Bool - } + } deriving (Show) flatten :: [ResourceTree a] -> [FlatResource a] flatten = diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index 38e27c93..7dd1a9dc 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -1,5 +1,5 @@ name: yesod-core -version: 1.6.1 +version: 1.6.2 license: MIT license-file: LICENSE author: Michael Snoyman