Conversation
georgefst
commented
Sep 13, 2020
georgefst
commented
Sep 13, 2020
georgefst
commented
Sep 13, 2020
Copy/paste error from 'defaultPostProcess'.
georgefst
commented
Sep 13, 2020
georgefst
commented
Sep 13, 2020
georgefst
commented
Sep 13, 2020
| -- only thing we will be doing with it is turning it /back/ into a string | ||
| -- at some stage, so we might as well cut out the middle man and store it | ||
| -- directly like this. | ||
| | CustomExpr Style !String |
Collaborator
Author
There was a problem hiding this comment.
This opens up a lot of flexibility. But it feels slightly ugly, since we will never actually parse a CustomExpr. We could formalise that fact with GADTs and DataKinds, but it's possibly unwarranted complexity.
cdepillabout
approved these changes
Sep 15, 2020
Owner
cdepillabout
left a comment
There was a problem hiding this comment.
This looks pretty good to me!
Helps with defining Show instance.
should probably be undone, effectively just stashing them
Collaborator
Author
|
I'm spitballing here, and I'm not sure where it falls on a spectrum anywhere from making this redundant to being completely orthogonal, but anyway, if I ever return to this, I think we should look in to integrating import Data.Data
import Data.Generics.Aliases
import Text.Pretty.Simple
gshowWith :: (Data a, Typeable b) => (b -> String) -> a -> String
gshowWith f x = gshowsWith f x ""
gshowsWith :: (Data a, Typeable b) => (b -> String) -> a -> ShowS
gshowsWith f =
( \t ->
showChar '('
. (showString . showConstr . toConstr $ t)
. (foldr (.) id . gmapQ ((showChar ' ' .) . gshowsWith f) $ t)
. showChar ')'
)
`extQ` (shows :: String -> ShowS)
-- only here do we modify the definition of `gshows`
`extQ` ((++) . f)
data Example = Example Int String Word | Rec () Example deriving (Data, Typeable)
example :: Example
example = Rec () $ Example 42 "Hello" 15
main :: IO ()
main =
pPrintString $
gshowWith
(\(i :: Int) -> "<int: " ++ show i ++ ">")
example( Rec ( () )
( Example <int: 42> "Hello" ( 15 ) )
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ended up writing a fix for #39, to help with a script I was writing this afternoon.
Not quite sure about the details of the API yet.
Tests expected to fail right now, though fixes should be trivial. And new tests will be added anyway.