@@ -246,124 +246,3 @@ maybeYouWant prefix suggestions =
246246 ++ "Maybe you want one of the following?\n"
247247 ++ concatMap ("\n "++) suggestions
248248
249−
250−{--
251−(.=.) key value =
252− key .= (value :: String)
253−
254−
255−errorToJson :: LError -> Json.Value
256−errorToJson (A.A region err) =
257− Json.object (generals ++ specifics)
258− where
259− generals =
260− [ "category" .=. "canonicalization"
261− , "region" .= region
262− ]
263−
264− specifics =
265− case err of
266− Var (VarError kind name varProblem) ->
267− [ "kind" .= kind
268− , "name" .= name
269− ]
270− ++ varProblemToJson varProblem
271−
272− Alias aliasError ->
273− case aliasError of
274− ArgMismatch name expected actual ->
275− [ "tag" .=. "alias-args"
276− , "name" .= Var.toString name
277− , "expected-args" .= expected
278− , "actual-args" .= actual
279− ]
280−
281− Recursive [(name, tvars, tipe)] ->
282− [ "tag" .=. "recursive-alias"
283− ]
284−
285− Recursive aliases ->
286− [ "tag" .=. "mutually-recursive-aliases"
287− ]
288−
289− Import moduleName importError ->
290− case importError of
291− ModuleNotFound suggestions ->
292− [ "tag" .=. "unknown-import"
293− , "name" .= moduleName
294− , "suggestions" .= suggestions
295− ]
296− ValueNotFound name suggestions ->
297− []
298−
299− Export name suggestions ->
300− []
301−
302− Port portError ->
303− []
304−
305−
306−varProblemToJson :: VarProblem -> [Json.Pair]
307−varProblemToJson varProblem =
308− let details tag suggestions =
309− [ "tag" .=. tag
310− , "suggestions" .= suggestions
311− ]
312− in
313− case varProblem of
314− Ambiguous possibilities ->
315− details "ambiguous" possibilities
316−
317− UnknownQualifier possibleModules ->
318− details
319− "unknown-qualifier"
320− (map Module.nameToString possibleModules)
321−
322− QualifiedUnknown possibilities ->
323− details "qualified-unknown" possibilities
324−
325− ExposedUnknown closeExposed closeQualified ->
326− details "exposed-unknown" (closeExposed ++ closeQualified)
327−--}
328−
329−{-- TO STRING
330−
331−mutuallyRecursiveMessage :: String
332−mutuallyRecursiveMessage =
333− "The following type aliases are mutually recursive, forming an \
334− \infinite type. When you expand them, they just keep getting bigger:"
335−
336−
337−typeAliasErrorSegue :: String
338−typeAliasErrorSegue =
339− "Try this instead:"
340−
341−
342−typeAliasErrorExplanation :: String
343−typeAliasErrorExplanation =
344− "It looks very similar, but the 'type' keyword creates a brand new type, \
345− \not just an alias for an existing one. This lets us avoid infinitely \
346− \expanding it during type inference."
347−
348−
349−typeAlias
350− :: (String, [String], Type.Type var)
351− -> D.Declaration' pk def var expr
352−typeAlias (n,ts,t) =
353− D.TypeAlias n ts t
354−
355−
356−datatype
357− :: (String, [String], Type.Type var)
358− -> D.Declaration' pk def var expr
359−datatype (n,ts,t) =
360− D.Datatype n ts [(n,[t])]
361−
362−
363−indented :: [D.ValidDecl] -> Doc
364−indented decls =
365− P.vcat (map prty decls) <> P.text "\n"
366− where
367− prty decl = P.text "\n " <> pretty decl
368−
369−--}