mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-15 14:35:01 +03:00
Round trip working with new framework
This commit is contained in:
parent
301327f29f
commit
ae8734d117
@ -58,5 +58,6 @@ decodeResponse : Decoder a -> Http.Response String -> Result (Status String) a
|
||||
decodeResponse p r = case r of
|
||||
Http.Success body -> case Decoder.decodeString p body of
|
||||
Result.Err e -> Result.Err (Failed e)
|
||||
Result.Ok a -> Result.Ok a
|
||||
Http.Waiting -> Result.Err Waiting
|
||||
Http.Failure code body -> Result.Err <| Failed ("error " ++ toString code ++ "\n" ++ body)
|
||||
|
@ -404,7 +404,8 @@ withStatus r = case r of
|
||||
Result.Err status -> \model ->
|
||||
let f s = case status of
|
||||
JR.Inactive -> List.drop 1 s
|
||||
_ -> status :: s
|
||||
JR.Waiting -> status :: s
|
||||
JR.Failed e -> let l = Debug.log e () in status :: s
|
||||
in norequest { model | status <- f model.status }
|
||||
Result.Ok action -> action
|
||||
|
||||
@ -413,34 +414,35 @@ search2 searchbox origin reqs =
|
||||
let openEdit r = case r of
|
||||
Open term path -> Just (term,path)
|
||||
_ -> Nothing
|
||||
--openEdit' =
|
||||
-- let go oe model = norequest (refreshExplorer searchbox { model | localInfo <- Just oe })
|
||||
-- in Signal.map openEdit reqs
|
||||
-- |> JR.send (Node.localInfo host `JR.to` go) (model0.term, [])
|
||||
-- |> Signal.map withStatus
|
||||
--search r = case r of
|
||||
-- Search typ query -> Just (typ,query)
|
||||
-- _ -> Nothing
|
||||
--declare r = case r of
|
||||
-- Declare term -> Just term
|
||||
-- _ -> Nothing
|
||||
--edit r = case r of
|
||||
-- -- todo: reroot the request to point to tightest bound term
|
||||
-- Edit rootPath relPath action term -> Just (rootPath,relPath,action,term)
|
||||
-- _ -> Nothing
|
||||
--edit' =
|
||||
-- let go (path,old,new) model = case Term.at path model.term of
|
||||
-- Nothing -> norequest model
|
||||
-- Just old' ->
|
||||
-- if old == old'
|
||||
-- then case Term.set path model.term new of
|
||||
-- Just term -> let m2 = { model | term <- term }
|
||||
-- in norequest (refreshPanel (Just searchbox) origin m2)
|
||||
-- Nothing -> norequest model
|
||||
-- else norequest model
|
||||
-- in Signal.map edit reqs
|
||||
-- |> JR.send (Node.editTerm host `JR.to` go) ([],[],Action.Noop,model0.term)
|
||||
-- |> Signal.map withStatus
|
||||
openEdit' =
|
||||
let go oe model =
|
||||
norequest (refreshExplorer searchbox { model | localInfo <- Just (Debug.log "info" oe) })
|
||||
in Signal.map openEdit reqs
|
||||
|> JR.send (Node.localInfo host `JR.to` go) (model0.term, [])
|
||||
|> Signal.map withStatus
|
||||
search r = case r of
|
||||
Search typ query -> Just (typ,query)
|
||||
_ -> Nothing
|
||||
declare r = case r of
|
||||
Declare term -> Just term
|
||||
_ -> Nothing
|
||||
edit r = case r of
|
||||
-- todo: reroot the request to point to tightest bound term
|
||||
Edit rootPath relPath action term -> Just (rootPath,relPath,action,term)
|
||||
_ -> Nothing
|
||||
edit' =
|
||||
let go (path,old,new) model = case Term.at path model.term of
|
||||
Nothing -> norequest model
|
||||
Just old' ->
|
||||
if old == old'
|
||||
then case Term.set path model.term new of
|
||||
Just term -> let m2 = { model | term <- term }
|
||||
in norequest (refreshPanel (Just searchbox) origin m2)
|
||||
Nothing -> norequest model
|
||||
else norequest model
|
||||
in Signal.map edit reqs
|
||||
|> JR.send (Node.editTerm host `JR.to` go) ([],[],Action.Noop,model0.term)
|
||||
|> Signal.map withStatus
|
||||
metadatas r = case r of
|
||||
Metadatas rs -> Just rs
|
||||
_ -> Nothing
|
||||
@ -453,7 +455,7 @@ search2 searchbox origin reqs =
|
||||
|> JR.send (Node.metadatas host `JR.to` go) []
|
||||
|> Signal.map withStatus
|
||||
noop model = norequest model
|
||||
in Signal.constant noop-- openEdit' `Signal.merge` metadatas' `Signal.merge` edit'
|
||||
in openEdit' `Signal.merge` metadatas' `Signal.merge` edit'
|
||||
|
||||
main =
|
||||
let origin = (15,15)
|
||||
@ -474,7 +476,7 @@ main =
|
||||
(search2 (Signal.send inputs.searchbox) origin)
|
||||
{ model0 | term <- Terms.int 42 }
|
||||
debug model =
|
||||
let summary model = model.explorer
|
||||
in Debug.watchSummary "model" summary model
|
||||
model |> Debug.watchSummary "explorer" .explorer
|
||||
|> Debug.watchSummary "status" .status
|
||||
ms' = Signal.map debug ms
|
||||
in Signal.map view ms'
|
||||
|
@ -31,7 +31,7 @@ type Kind = Star | KArrow Kind Kind
|
||||
decodeKind : Decoder Kind
|
||||
decodeKind = Decoder.union' <| \t ->
|
||||
if | t == "Star" -> Decoder.unit Star
|
||||
| t == "Arrow" -> Decoder.map2 KArrow decodeKind decodeKind
|
||||
| t == "Arrow" -> Decoder.product2 KArrow decodeKind decodeKind
|
||||
|
||||
decodeLiteral : Decoder Literal
|
||||
decodeLiteral = Decoder.union' <| \t ->
|
||||
@ -43,12 +43,12 @@ decodeLiteral = Decoder.union' <| \t ->
|
||||
decodeType : Decoder Type
|
||||
decodeType = Decoder.union' <| \t ->
|
||||
if | t == "Unit" -> Decoder.map Unit decodeLiteral
|
||||
| t == "Arrow" -> Decoder.map2 Arrow decodeType decodeType
|
||||
| t == "Arrow" -> Decoder.product2 Arrow decodeType decodeType
|
||||
| t == "Universal" -> Decoder.map Universal V.decode
|
||||
| t == "Existential" -> Decoder.map Existential V.decode
|
||||
| t == "Kind" -> Decoder.map2 Ann decodeType decodeKind
|
||||
| t == "Constrain" -> Decoder.map2 Constrain decodeType (Decoder.unit ())
|
||||
| t == "Forall" -> Decoder.map2 Forall V.decode decodeType
|
||||
| t == "Kind" -> Decoder.product2 Ann decodeType decodeKind
|
||||
| t == "Constrain" -> Decoder.product2 Constrain decodeType (Decoder.unit ())
|
||||
| t == "Forall" -> Decoder.product2 Forall V.decode decodeType
|
||||
|
||||
encodeKind : Encoder Kind
|
||||
encodeKind k = case k of
|
||||
|
Loading…
Reference in New Issue
Block a user