diff options
Diffstat (limited to 'compiler/GHC/Runtime/Heap/Inspect.hs')
-rw-r--r-- | compiler/GHC/Runtime/Heap/Inspect.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/GHC/Runtime/Heap/Inspect.hs b/compiler/GHC/Runtime/Heap/Inspect.hs index cd2e20cc19..8357eb1bdb 100644 --- a/compiler/GHC/Runtime/Heap/Inspect.hs +++ b/compiler/GHC/Runtime/Heap/Inspect.hs @@ -23,7 +23,7 @@ module GHC.Runtime.Heap.Inspect( constrClosToName -- exported to use in test T4891 ) where -import GHC.Prelude +import GHC.Prelude hiding (head, init, last, tail) import GHC.Platform import GHC.Runtime.Interpreter as GHCi @@ -67,6 +67,8 @@ import GHC.IO (throwIO) import Control.Monad import Data.Maybe import Data.List ((\\)) +import Data.List.NonEmpty (NonEmpty (..)) +import qualified Data.List.NonEmpty as NE import GHC.Exts import qualified Data.Sequence as Seq import Data.Sequence (viewl, ViewL(..)) @@ -431,13 +433,14 @@ cPprTermBase y = --Note pprinting of list terms is not lazy ppr_list :: Precedence -> Term -> m SDoc ppr_list p (Term{subTerms=[h,t]}) = do - let elems = h : getListTerms t - isConsLast = not (termType (last elems) `eqType` termType h) + let elems = h :| getListTerms t + elemList = toList elems + isConsLast = not (termType (NE.last elems) `eqType` termType h) is_string = all (isCharTy . ty) elems chars = [ chr (fromIntegral w) - | Term{subTerms=[Prim{valRaw=[w]}]} <- elems ] + | Term{subTerms=[Prim{valRaw=[w]}]} <- elemList ] - print_elems <- mapM (y cons_prec) elems + print_elems <- mapM (y cons_prec) elemList if is_string then return (Ppr.doubleQuotes (Ppr.text chars)) else if isConsLast |