Skip to content

Commit a75cef6

Browse files
committed
code compiles after changes
1 parent 6225c70 commit a75cef6

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

dhall-lsp-server/src/Dhall/LSP/Backend/Formatting.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Dhall.LSP.Backend.Formatting (formatExpr, formatExprWithHeader) where
33
import Data.Text (Text)
44
import Dhall.Core (Expr)
55
import Dhall.Parser (Header (..))
6-
import Dhall.Pretty (CharacterSet (..))
6+
import Dhall.Pretty (ChooseCharacterSet (..), chooseCharsetOrUseDefault)
77
import Dhall.Src (Src)
88

99
import qualified Dhall.Pretty

dhall-lsp-server/src/Dhall/LSP/Backend/Parsing.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Dhall.Core
2424
import Dhall.Parser
2525
import Dhall.Parser.Expression (importHash_, importType_, localOnly)
2626
import Dhall.Parser.Token hiding (text)
27+
import Dhall.Pretty ( ChooseCharacterSet(Specify) )
2728
import Text.Megaparsec
2829
( SourcePos (..)
2930
, anySingle
@@ -295,7 +296,7 @@ binderExprFromText txt =
295296
<|> (do cs' <- skipManyTill anySingle _arrow; return (cs', holeExpr))
296297
whitespace
297298
inner <- parseBinderExpr
298-
return (Pi (Just (cs <> cs')) name typ inner)
299+
return (Pi (Specify (cs <> cs')) name typ inner)
299300

300301
lambdaBinder = do
301302
cs <- _lambda
@@ -312,4 +313,4 @@ binderExprFromText txt =
312313
<|> (do cs' <- skipManyTill anySingle _arrow; return (cs', holeExpr))
313314
whitespace
314315
inner <- parseBinderExpr
315-
return (Lam (Just (cs <> cs')) (makeFunctionBinding name typ) inner)
316+
return (Lam (Specify (cs <> cs')) (makeFunctionBinding name typ) inner)

dhall-lsp-server/src/Dhall/LSP/State.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Data.Dynamic (Dynamic)
1818
import Data.Map.Strict (Map, empty)
1919
import Data.Text (Text)
2020
import Dhall.LSP.Backend.Dhall (Cache, DhallError, emptyCache)
21-
import Dhall.Pretty (CharacterSet)
21+
import Dhall.Pretty (ChooseCharacterSet(..))
2222
import Language.LSP.Server (LspT)
2323

2424
import qualified Language.LSP.Protocol.Types as J
@@ -43,15 +43,15 @@ data ServerConfig = ServerConfig
4343
} deriving Show
4444

4545
instance Default ServerConfig where
46-
def = ServerConfig { chosenCharacterSet = Nothing }
46+
def = ServerConfig { chosenCharacterSet = AutoInferCharSet }
4747

4848
-- We need to derive the FromJSON instance manually in order to provide defaults
4949
-- for absent fields.
5050
instance FromJSON ServerConfig where
5151
parseJSON = withObject "settings" $ \v -> do
5252
s <- v .: "vscode-dhall-lsp-server"
5353
flip (withObject "vscode-dhall-lsp-server") s $ \o -> ServerConfig
54-
<$> o .:? "character-set" .!= Nothing
54+
<$> o .:? "character-set" .!= AutoInferCharSet
5555

5656
data ServerState = ServerState
5757
{ _importCache :: Cache -- ^ The dhall import cache

dhall-openapi/openapi-to-dhall/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import Dhall.Kubernetes.Types
3636
)
3737
import System.FilePath ((</>))
3838

39-
import Dhall.Pretty.Internal (ChooseCharacterSet(..))
39+
import Dhall.Pretty (ChooseCharacterSet(..))
4040

4141
import qualified Data.List as List
4242
import qualified Data.Map.Strict as Data.Map

dhall/src/Dhall/Pretty.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ module Dhall.Pretty
1212
, detectCharacterSet
1313
, prettyCharacterSet
1414

15+
, ChooseCharacterSet(..)
16+
, chooseCharsetOrUseDefault
17+
1518
, Dhall.Pretty.Internal.layout
1619
, Dhall.Pretty.Internal.layoutOpts
1720

dhall/src/Dhall/Pretty/Internal.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ import qualified Prettyprinter.Render.String as Pretty
115115
import qualified Prettyprinter.Render.Terminal as Terminal
116116
import qualified Prettyprinter.Render.Text as Pretty
117117
import qualified Text.Printf as Printf
118+
import Data.Aeson (Value(Null))
118119

119120
{-| Annotation type used to tag elements in a pretty-printed document for
120121
syntax highlighting purposes
@@ -173,7 +174,12 @@ instance Semigroup ChooseCharacterSet where
173174

174175
instance Monoid ChooseCharacterSet where
175176
mempty = AutoInferCharSet
176-
177+
178+
instance FromJSON ChooseCharacterSet where
179+
parseJSON Null = pure mempty
180+
parseJSON v@(String _) = fmap Specify (parseJSON v)
181+
parseJSON v = typeMismatch "String" v
182+
177183
chooseCharsetOrUseDefault :: CharacterSet -> ChooseCharacterSet -> CharacterSet
178184
chooseCharsetOrUseDefault c chooseCS = case chooseCS of
179185
AutoInferCharSet -> c

0 commit comments

Comments
 (0)