diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index 582240963..1c6242de6 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -209,7 +209,7 @@ instance Show1 Error where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Error instance Tokenize Error where - prettyPrint = ignore + tokenize = ignore instance Named String where nameOf _ = "string" diff --git a/src/Data/Syntax/Literal.hs b/src/Data/Syntax/Literal.hs index f741abdba..2920d6e8e 100644 --- a/src/Data/Syntax/Literal.hs +++ b/src/Data/Syntax/Literal.hs @@ -34,7 +34,7 @@ instance Evaluatable Boolean where eval (Boolean x) = rvalBox (boolean x) instance Tokenize Boolean where - prettyPrint = yield . Truth . booleanContent + tokenize = yield . Truth . booleanContent -- Numeric @@ -65,7 +65,7 @@ instance Evaluatable Data.Syntax.Literal.Float where rvalBox =<< (float <$> either (const (throwEvalError (FloatFormatError s))) pure (parseScientific s)) instance Tokenize Data.Syntax.Literal.Float where - prettyPrint = yield . Fragment . floatContent + tokenize = yield . Fragment . floatContent -- Rational literals e.g. `2/3r` newtype Rational a = Rational { value :: Text } @@ -139,7 +139,7 @@ instance Evaluatable TextElement where eval (TextElement x) = rvalBox (string x) instance Tokenize TextElement where - prettyPrint = yield . Fragment . textElementContent + tokenize = yield . Fragment . textElementContent -- | A sequence of textual contents within a string literal. newtype EscapeSequence a = EscapeSequence { value :: Text } @@ -162,7 +162,7 @@ instance Show1 Null where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Null where eval _ = rvalBox null instance Tokenize Null where - prettyPrint _ = yield Nullity + tokenize _ = yield Nullity newtype Symbol a = Symbol { symbolElements :: [a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1) @@ -210,7 +210,7 @@ instance Evaluatable Array where eval (Array a) = rvalBox =<< array =<< traverse subtermAddress a instance Tokenize Array where - prettyPrint t = within List $ + tokenize t = within List $ let withCommas = intersperse (yield Separator) (toList t) in yield Open *> sequenceA_ withCommas *> yield Close @@ -225,7 +225,7 @@ instance Evaluatable Hash where eval t = rvalBox =<< (hash <$> traverse (subtermValue >=> asPair) (hashElements t)) instance Tokenize Hash where - prettyPrint t = within Associative $ + tokenize t = within Associative $ let withCommas = intersperse (yield Separator) (toList t) in yield Open *> sequenceA_ withCommas *> yield Close @@ -241,7 +241,7 @@ instance Evaluatable KeyValue where rvalBox =<< (kvPair <$> key <*> value) instance Tokenize KeyValue where - prettyPrint (KeyValue k v) = within Pair $ + tokenize (KeyValue k v) = within Pair $ k *> yield Separator *> v newtype Tuple a = Tuple { tupleContents :: [a] } diff --git a/src/Reprinting/Tokenize.hs b/src/Reprinting/Tokenize.hs index 0a173cc31..cebf30fe6 100644 --- a/src/Reprinting/Tokenize.hs +++ b/src/Reprinting/Tokenize.hs @@ -66,15 +66,15 @@ ignore = const (pure ()) -- pretty print the value of the supplied constructor in its AST context. class (Show1 constr, Traversable constr) => Tokenize constr where -- | Should emit control and data tokens. - prettyPrint :: FAlgebra constr (Tokenizer ()) + tokenize :: FAlgebra constr (Tokenizer ()) -- | Sums of reprintable terms are reprintable. instance (Apply Show1 fs, Apply Functor fs, Apply Foldable fs, Apply Traversable fs, Apply Tokenize fs) => Tokenize (Sum fs) where - prettyPrint = apply @Tokenize prettyPrint + tokenize = apply @Tokenize tokenize -- | Annotated terms are reprintable and operate in a context derived from the annotation. instance (HasField fields History, Show (Record fields), Tokenize a) => Tokenize (TermF a (Record fields)) where - prettyPrint t = withHistory t (prettyPrint (termFOut t)) + tokenize t = withHistory t (tokenize (termFOut t)) -- | The top-level function. Pass in a 'Source' and a 'Term' and -- you'll get out a 'Seq' of 'Token's for later processing. @@ -138,7 +138,7 @@ descend t = do let into s = withHistory (subterm s) (subtermRef s) case (hist, strat) of (Unmodified _, _) -> traverse_ into t - (Refactored _, PrettyPrinting) -> prettyPrint (fmap into t) + (Refactored _, PrettyPrinting) -> tokenize (fmap into t) (Refactored r, Reprinting) -> do crs <- gets _cursor src <- asks _source @@ -146,5 +146,5 @@ descend t = do log ("slicing: " <> show delimiter) chunk (slice delimiter src) modify (set cursor (start r)) - prettyPrint (fmap (withStrategy PrettyPrinting . into) t) + tokenize (fmap (withStrategy PrettyPrinting . into) t) modify (set cursor (end r))