diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 3187f6734..dee7d6086 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -155,7 +155,7 @@ determiner (LeafInfo "else block" _ _) = "an" determiner (LeafInfo "ensure block" _ _) = "an" determiner (LeafInfo "when block" _ _) = "a" determiner (LeafInfo "anonymous function" _ _) = "an" -determiner (BranchInfo bs _ _) = determiner (last bs) +determiner (BranchInfo bs _ _) = maybe "" determiner (snd <$> unsnoc bs) determiner _ = "the" toLeafInfos :: DiffInfo -> [JSONSummary Doc SourceSpan] diff --git a/src/Prologue.hs b/src/Prologue.hs index a59ad3cac..61a7687e5 100644 --- a/src/Prologue.hs +++ b/src/Prologue.hs @@ -5,11 +5,10 @@ module Prologue , (***) , hylo, cata, para, ana , module Data.Hashable -, last ) where import Protolude as X -import Data.List (lookup, last) +import Data.List (lookup) import Control.Comonad.Trans.Cofree as X import Control.Monad.Trans.Free as X diff --git a/src/Source.hs b/src/Source.hs index 2fdd4fc4c..30d6aafe9 100644 --- a/src/Source.hs +++ b/src/Source.hs @@ -103,7 +103,7 @@ sourceSpanToRange source SourceSpan{..} = Range start end rangeToSourceSpan :: Source Char -> Range -> SourceSpan rangeToSourceSpan source range@Range{} = SourceSpan startPos endPos where startPos = maybe (SourcePos 1 1) (toStartPos 1) (head lineRanges) - endPos = toEndPos (length lineRanges) (last lineRanges) + endPos = toEndPos (length lineRanges) (fromMaybe (rangeAt 0) (snd <$> unsnoc lineRanges)) lineRanges = actualLineRanges range source toStartPos line range = SourcePos line (start range) toEndPos line range = SourcePos line (end range)