@@ -0,0 +1,46 @@
1+{- | This module aims to make it easier to create dev tools for Elm.
3+ It provides the ability to:
5+ * Detect problems in a program
6+ * Figure out types of particular expressions
7+ * Canonicalize variables
8+ * Convert expressions to JS and HTML
10+ This module gives limeted access to the structure of an Elm Program.
11+ Giving full access would expose many internal details that are likely to
12+ change as Elm progresses. These details have been hidden to avoid breaking
15+module Language.Elm.DevTools where
19+-- | Parse an Elm program into an AST.
20+parse :: String -> Either [Problem] Program
22+-- | Get the type of a region of the program. Lets you look
23+-- up the type of particular values and expressions.
24+typeOf :: Program -> Region -> Either [Problem] String
26+-- | Canonicalize a variable. So in a normal module `map` would be canonicalized
28+canonicalize :: Program -> Region -> [String]
30+-- | Any problem that may come up while parsing or typing a program.
31+-- All problems come with a region that is causing the problem.
32+data Problem = Problem { message :: String, region :: Region }
37+-- | Represents a region, spanning two points in the source code.
38+data Region = Region { start :: (Row,Column), end :: (Row,Column) }
40+-- | Takes a specific point in the source code, such as the cursor position.
41+-- It then determines the region that best represents that point. When the
42+-- cursor is within a variable, it chooses the variable. When the cursor is
43+-- on parentheses, it selects the region within the parentheses. When the
44+-- cursor is on keywords like let, it chooses the whole let-expression.
45+region :: (Row,Column) -> Region
46+region pos = Region pos pos