1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00

Define a function computing a label using a Show1 instance.

This commit is contained in:
Rob Rix 2017-05-31 15:02:19 -04:00
parent 97dc5635ae
commit b2ad332ff0

View File

@ -4,6 +4,7 @@ module Interpreter
, decoratingWith
, diffTermsWith
, comparableByGAlign
, constructorLabel
, runAlgorithm
, runAlgorithmSteps
) where
@ -12,7 +13,7 @@ import Algorithm
import Control.Monad.Free.Freer
import Data.Align.Generic
import Data.Functor.Both
import Data.Functor.Classes (Eq1)
import Data.Functor.Classes (Eq1, Show1 (liftShowsPrec))
import RWS
import Data.Record
import Data.These
@ -50,6 +51,9 @@ getLabel (h :< t) = (Info.category h, case t of
Leaf s -> Just s
_ -> Nothing)
constructorLabel :: Show1 f => TermF f a b -> ByteString
constructorLabel (_ :< f) = toS (liftShowsPrec (\ _ _ _ -> "") (\ _ _ -> "") 0 f "")
-- | Run an Algorithm to completion by repeated application of a stepping operation and return its result.
runAlgorithm :: forall f result
. (forall x. f x -> Freer f x)