Skip to content

Commit

Permalink
Merge pull request #2664 from setupminimal/explicit-parser-exports
Browse files Browse the repository at this point in the history
Add Explicit Export Lists for Modules that involve Parsing
  • Loading branch information
aryairani authored Feb 1, 2024
2 parents f98ea54 + 544f294 commit cfb58a6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 48 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The format for this list: name, GitHub handle
* Nicole Prindle (@nprindle)
* Harald Gliebe (@hagl)
* Phil de Joux (@philderbeast)
* Daroc Alden (@setupminimal)
* Travis Staton (@tstat)
* Dan Freeman (@dfreeman)
* Emil Hotkowski (@emilhotkowski)
Expand Down
59 changes: 13 additions & 46 deletions parser-typechecker/src/Unison/PrintError.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{-# LANGUAGE RecordWildCards #-}

module Unison.PrintError where
module Unison.PrintError
( Env,
defaultWidth,
prettyParseError,
prettyResolutionFailures,
prettyVar,
printNoteWithSource,
renderCompilerBug,
renderNoteAsANSI,
renderParseErrorAsANSI,
renderParseErrors,
)
where

import Control.Lens ((%~))
import Control.Lens.Tuple (_1, _2, _3)
Expand All @@ -19,7 +31,6 @@ import Data.Text qualified as Text
import Text.Megaparsec qualified as P
import Unison.ABT qualified as ABT
import Unison.Builtin.Decls (unitRef, pattern TupleType')
import Unison.Codebase.Path qualified as Path
import Unison.ConstructorReference (ConstructorReference, GConstructorReference (..))
import Unison.HashQualified (HashQualified)
import Unison.HashQualified' qualified as HQ'
Expand Down Expand Up @@ -81,12 +92,6 @@ pattern Type2 = Color.Green
pattern ErrorSite :: Color
pattern ErrorSite = Color.HiRed

pattern TypeKeyword :: Color
pattern TypeKeyword = Color.Yellow

pattern AbilityKeyword :: Color
pattern AbilityKeyword = Color.Green

pattern Identifier :: Color
pattern Identifier = Color.Bold

Expand Down Expand Up @@ -115,18 +120,6 @@ fromOverHere src spots0 removing =
1 -> "\n from right here:\n\n" <> showSource src spots
_ -> "\n from these spots, respectively:\n\n" <> showSource src spots

showTypeWithProvenance ::
(Var v, Annotated a, Ord style) =>
Env ->
String ->
style ->
Type v a ->
Pretty (AnnotatedText style)
showTypeWithProvenance env src color typ =
style color (renderType' env typ)
<> ".\n"
<> fromOverHere' src [styleAnnotated color typ] []

styleAnnotated :: (Annotated a) => sty -> a -> Maybe (Range, sty)
styleAnnotated sty a = (,sty) <$> rangeForAnnotated a

Expand Down Expand Up @@ -1211,9 +1204,6 @@ renderSuggestion env sug =
spaces :: (IsString a, Monoid a) => (b -> a) -> [b] -> a
spaces = intercalateMap " "

arrows :: (IsString a, Monoid a) => (b -> a) -> [b] -> a
arrows = intercalateMap " ->"

commas :: (IsString a, Monoid a) => (b -> a) -> [b] -> a
commas = intercalateMap ", "

Expand Down Expand Up @@ -1244,17 +1234,6 @@ showConstructor env r =
fromString . HQ.toString $
PPE.patternName env r

styleInOverallType ::
(Var v, Annotated a, Eq a) =>
Env ->
C.Type v a ->
C.Type v a ->
Color ->
Pretty ColorText
styleInOverallType e overallType leafType c = renderType e f overallType
where
f loc s = if loc == ABT.annotation leafType then Color.style c <$> s else s

_posToEnglish :: (IsString s) => L.Pos -> s
_posToEnglish (L.Pos l c) =
fromString $ "Line " ++ show l ++ ", Column " ++ show c
Expand Down Expand Up @@ -1929,15 +1908,6 @@ showSource src annotations =
showSource1 :: (Ord a) => String -> (Range, a) -> Pretty (AnnotatedText a)
showSource1 src annotation = showSource src [annotation]

findTerm :: Seq (C.PathElement v loc) -> Maybe loc
findTerm = go
where
go (C.InSynthesize t :<| _) = Just $ ABT.annotation t
go (C.InCheck t _ :<| _) = Just $ ABT.annotation t
go (C.InSynthesizeApp _ t _ :<| _) = Just $ ABT.annotation t
go (_ :<| t) = go t
go Empty = Nothing

prettyTypecheckError ::
(Var v, Ord loc, Show loc, Parser.Annotated loc) =>
C.ErrorNote v loc ->
Expand Down Expand Up @@ -2027,6 +1997,3 @@ useExamples =
(Pr.blue "use .foo bar.baz", Pr.wrap "Introduces `bar.baz` as a local alias for the absolute name `.foo.bar.baz`")
]
]

prettyPath' :: Path.Path' -> Pretty ColorText
prettyPath' p' = Pr.blue (Pr.shown p')
4 changes: 3 additions & 1 deletion parser-typechecker/src/Unison/Syntax/FileParser.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module Unison.Syntax.FileParser where
module Unison.Syntax.FileParser
( file
) where

import Control.Lens
import Control.Monad.Reader (asks, local)
Expand Down
8 changes: 7 additions & 1 deletion parser-typechecker/src/Unison/Syntax/TypeParser.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
module Unison.Syntax.TypeParser where
{-# LANGUAGE OverloadedStrings #-}

module Unison.Syntax.TypeParser
( computationType
, valueType
, valueTypeLeaf
) where

import Control.Monad.Reader (asks)
import Data.Set qualified as Set
Expand Down

0 comments on commit cfb58a6

Please sign in to comment.