Fixing up imports

This commit is contained in:
Paul Chiusano 2014-09-25 10:53:25 -04:00
parent d584129780
commit fc5162e835
3 changed files with 27 additions and 23 deletions

View File

@ -22,13 +22,15 @@ import Text
import Elmz.Signal as Signals
import Elmz.Maybe
type Path = Path.Path -- to avoid conflict with Graphics.Collage.Path
nums : E.Term
nums = let f x = E.Lit (E.Number (toFloat x))
in E.Lit (E.Vector (Array.fromList (map f [0..20])))
expr = E.App (E.App (E.Ref "foo") nums) (E.App (E.Ref "baz") (E.Lit (E.Str "hello world!")))
resolvedPath : Signal E.Term -> Signal (Maybe Path.Path) -> Signal (Maybe Path.Path)
resolvedPath : Signal E.Term -> Signal (Maybe Path) -> Signal (Maybe Path)
resolvedPath e pathUnderPtr =
let edit {x,y} e = \p' -> p' |>
(if y == 1 then E.up else identity) |>
@ -48,13 +50,13 @@ terms = constant expr
layouts : Signal Int
-> Signal E.Term
-> Signal (L.Layout { hash : Hash, path : Path.Path, selectable : Bool })
-> Signal (L.Layout { hash : Hash, path : Path, selectable : Bool })
layouts availableWidth terms =
let go w e = E.layout e { key = "bar", availableWidth = w, metadata h = MD.anonymousTerm }
in go <~ availableWidth ~ terms
leafUnderPtr : Signal (L.Layout { hash : Hash, path : Path.Path, selectable : Bool })
-> Signal (Maybe { hash : Hash, path : Path.Path, selectable : Bool })
leafUnderPtr : Signal (L.Layout { hash : Hash, path : Path, selectable : Bool })
-> Signal (Maybe { hash : Hash, path : Path, selectable : Bool })
leafUnderPtr layout =
let go layout (x,y) =
let paths = L.atRanked (length << .path) layout (L.Region { x = x, y = y } 2 2)

View File

@ -12,6 +12,7 @@ import Unison.Parser (Parser, (#))
import Unison.Hash as H
import Unison.Var (I)
import Unison.Var as V
type Path = Path.Path -- to avoid conflict with Graphics.Collage.Path
data Sort = Type | Term
@ -19,7 +20,7 @@ type Metadata = {
sort : Sort,
names : Names,
-- for each var, and each scope (which points to a lambda body), what are the names of that var w/in that scope
locals : M.Dict I [(Path.Path,Names)],
locals : M.Dict I [(Path,Names)],
description : Maybe H.Hash,
annotation : H.Hash
}
@ -38,13 +39,13 @@ firstName ifEmpty md =
then ifEmpty
else (head md.names).name
resolveLocal : Metadata -> Path.Path -> I -> Symbol
resolveLocal : Metadata -> Path -> I -> Symbol
resolveLocal md p v =
let ns = localNames md p v
in if isEmpty ns then { name = show v, fixity = Prefix, precedence = 9 }
else head ns
localNames : Metadata -> Path.Path -> I -> Names
localNames : Metadata -> Path -> I -> Names
localNames env p v =
let trimmed = Path.trimToScope p
in case M.get v env.locals of
@ -119,11 +120,11 @@ parseMetadata =
(P.optional H.parse)
H.parse
parseLocals : Parser (M.Dict I [(Path.Path,Names)])
parseLocals : Parser (M.Dict I [(Path,Names)])
parseLocals =
P.map M.fromList (P.array (P.tuple2 V.parse (P.array (P.tuple2 Path.parsePath parseNames))))
jsonifyLocals : Jsonify (M.Dict I [(Path.Path,Names)])
jsonifyLocals : Jsonify (M.Dict I [(Path,Names)])
jsonifyLocals m = J.array (J.tuple2 V.jsonify (J.array (J.tuple2 Path.jsonifyPath jsonifyNames))) (M.toList m)
jsonifyMetadata : Jsonify Metadata

View File

@ -30,6 +30,7 @@ import Unison.Path as Path
import Unison.Var (I)
import Unison.Var as V
import Unison.Type as T
type Path = Path.Path -- to avoid conflict with Graphics.Collage.Path
data Literal
= Number Float
@ -49,7 +50,7 @@ todo : a
todo = todo
{-| Returns the subterm at the given path, if the path is valid. -}
at : Path.Path -> Term -> Maybe Term
at : Path -> Term -> Maybe Term
at p e = case (p,e) of
([], e) -> Just e
(Fn :: t, App f _) -> at t f
@ -61,12 +62,12 @@ at p e = case (p,e) of
_ -> Nothing
{-| Returns `True` if the path points to a valid subterm -}
valid : Term -> Path.Path -> Bool
valid : Term -> Path -> Bool
valid e p = isJust (at p e)
{-| Move path to point to leftmost child, or return `p` unmodified
if no such child exists. -}
down : Term -> Path.Path -> Path.Path
down : Term -> Path -> Path
down e p =
let go e = case e of
App f x -> p `snoc` Fn
@ -76,7 +77,7 @@ down e p =
in maybe p go (at p e)
{-| Move path to point to parent node in "logical" layout. -}
up : Path.Path -> Path.Path
up : Path -> Path
up p =
let go p = case p of
[] -> []
@ -88,19 +89,19 @@ up p =
{-| Move the path to its immediate sibling to the right,
or return `p` unmodified if no such sibling exists. -}
siblingR : Term -> Path.Path -> Path.Path
siblingR : Term -> Path -> Path
siblingR e p = increment (valid e) p
{-| Move the path to its immediate sibling to the right,
or return `p` unmodified if no such sibling exists. -}
siblingL : Term -> Path.Path -> Path.Path
siblingL : Term -> Path -> Path
siblingL e p = decrement (valid e) p
layout : Term -- term to render
-> { key : Hash
, availableWidth : Int
, metadata : Hash -> Metadata }
-> Layout { hash : Hash, path : Path.Path, selectable : Bool }
-> Layout { hash : Hash, path : Path, selectable : Bool }
layout expr env =
let
md = env.metadata env.key
@ -111,9 +112,9 @@ layout expr env =
if n <= 0 then empty else codeText (String.padLeft (n*2) ' ' "")
space2 = codeText " "
indentWidth = E.widthOf space2
paren : Bool -> { path : Path.Path, term : Term }
-> Layout { hash : Hash, path : Path.Path, selectable : Bool }
-> Layout { hash : Hash, path : Path.Path, selectable : Bool }
paren : Bool -> { path : Path, term : Term }
-> Layout { hash : Hash, path : Path, selectable : Bool }
-> Layout { hash : Hash, path : Path, selectable : Bool }
paren parenthesize cur e =
if parenthesize
then let t = tag cur.path
@ -128,8 +129,8 @@ layout expr env =
go : Bool
-> Int
-> Int
-> { path : Path.Path, term : Term }
-> Layout { hash : Hash, path : Path.Path, selectable : Bool }
-> { path : Path, term : Term }
-> Layout { hash : Hash, path : Path, selectable : Bool }
go allowBreak ambientPrec availableWidth cur =
case cur.term of
Var n -> codeText (Metadata.resolveLocal md cur.path n).name |> L.embed (tag cur.path)
@ -193,9 +194,9 @@ data Break a
break : Hash
-> (Hash -> Metadata)
-> Path.Path
-> Path
-> Term
-> Break { path : Path.Path, term : Term }
-> Break { path : Path, term : Term }
break hash md path expr =
let prefix f acc path = case f of
App f arg -> prefix f ({ path = path `snoc` Arg, term = arg } :: acc) (path `snoc` Fn)