From 55a6650aeb8e23bf86e648273e37c5d3c461bfe4 Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Fri, 13 Feb 2015 18:47:33 -0500 Subject: [PATCH] Updated editor binding to openEdit node function --- editor/src/Unison/Node.elm | 30 +++++++++++++++++++++--------- node/src/Unison/Node.hs | 4 ++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/editor/src/Unison/Node.elm b/editor/src/Unison/Node.elm index 2577eb70d..229e2c8ba 100644 --- a/editor/src/Unison/Node.elm +++ b/editor/src/Unison/Node.elm @@ -110,6 +110,27 @@ metadatas host params = let req host params = jsonGet (Encoder.list H.encode) host "metadata" params in decodeResponse (Decoder.object MD.decodeMetadata) <~ Http.send (Signal.map2 req host params) +type alias OpenEdit = + { current : Type + , admissible : Type + , locals : List Term + , focalApplications : List Int + , wellTypedLocals : List Term } + +openEdit : Signal Host + -> Signal (Term, Path) + -> Signal (Response OpenEdit) +openEdit host params = + let body = Encoder.tuple2 E.encodeTerm Path.encodePath + req host params = jsonPost body host "open-edit" params + decode = Decoder.product5 OpenEdit + T.decodeType + T.decodeType + (Decoder.list E.decodeTerm) + (Decoder.list Decoder.int) + (Decoder.list E.decodeTerm) + in decodeResponse decode <~ Http.send (Signal.map2 req host params) + search : Signal Host -> Signal (Maybe Type, Query) -> Signal (Response (List Term)) @@ -120,15 +141,6 @@ search host params = decode = decodeResponse (Decoder.list E.decodeTerm) in decode <~ Http.send (Signal.map2 req host params) -searchLocal : Signal Host - -> Signal (Hash, Path, Maybe Type) - -> Signal (Response (List Term)) -searchLocal host params = - let body = Encoder.tuple3 H.encode Path.encodePath (Encoder.optional T.encodeType) - req host params = jsonGet body host "search-local" params - decode = Decoder.list E.decodeTerm - in decodeResponse decode <~ Http.send (Signal.map2 req host params) - terms : Signal Host -> Signal (List Hash) -> Signal (Response (M.Dict Hash Term)) terms host params = let req host params = jsonGet (Encoder.list H.encode) host "terms" params diff --git a/node/src/Unison/Node.hs b/node/src/Unison/Node.hs index 0979113af..8560828b5 100644 --- a/node/src/Unison/Node.hs +++ b/node/src/Unison/Node.hs @@ -29,8 +29,8 @@ data Node m k t e = Node { -- returns ( current type -- , admissible type -- , local vars - -- , matching local applications - -- , matching local expressions ) + -- , well-typed applications of focus + -- , well-typed expressions involving local vars ) openEdit :: e -> P.Path -> Noted m (t, t, [e], [Int], [e]), -- | Search for a term, optionally constrained to be of the given type search :: Maybe t -> Query -> Noted m [e],