Skip to content

Commit

Permalink
First working iteration of interpreter integration
Browse files Browse the repository at this point in the history
  • Loading branch information
norm2782 committed Apr 1, 2012
1 parent ba454cf commit 571f58c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions resources/static/hjs/jcu.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,14 +96,18 @@ main = do
onDocumentReady init onDocumentReady init


initInterpreter :: IO () initInterpreter :: IO ()
initInterpreter = do initInterpreter = registerEvents [("#submitquery", Click, submitQuery)]
obj <- mkAnonObj where submitQuery _ = do obj <- mkAnonObj
ajaxQ GET ("/interpreter/" ++ encodeURIComponent "TODO") obj showInterpRes noop qryFld <- jQuery "#query"
return () -- TODO: Implement qry <- valJSString qryFld

ajaxQ GET ("/interpreter/" ++ fromJS (_encodeURIComponent qry)) obj showInterpRes noop
return True


showInterpRes :: AjaxCallback JSString showInterpRes :: AjaxCallback JSString
showInterpRes res str obj = return () -- TODO showInterpRes res str obj = do
op <- jQuery "#output"
_setHTML op res
return ()


initProofTree :: IO () initProofTree :: IO ()
initProofTree = do -- Rendering initProofTree = do -- Rendering
Expand Down
2 changes: 1 addition & 1 deletion src/Application.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ runInterpreterH = restrict forbiddenH $ do
let rules = [r |(DBRule _ _ r) <- rs] let rules = [r |(DBRule _ _ r) <- rs]
let result = solve rules emptyEnv [("0", goal)] let result = solve rules emptyEnv [("0", goal)]
shpref env (prefix, pr) = prefix ++ " " ++ show (subst env pr) shpref env (prefix, pr) = prefix ++ " " ++ show (subst env pr)
writeBS . BS.pack $ show $ concat [concatMap (show . shpref env) (reverse proof) ++ "\nsubstitution: " ++ show env | (proof, env) <- enumerateDepthFirst [] result] writeBS . BS.pack $ show $ concat [concatMap (shpref env) (reverse proof) ++ "<br/>\nsubstitution: " ++ show env | (proof, env) <- enumerateDepthFirst [] result]
else writeBS . BS.pack $ "There has been an error" -- show $ concat errs else writeBS . BS.pack $ "There has been an error" -- show $ concat errs


readStoredRulesH :: AppHandler () readStoredRulesH :: AppHandler ()
Expand Down
2 changes: 1 addition & 1 deletion src/JCU/Templates.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ loginHTML loginFailed frm = return $
interpreterHTML :: Reader AuthState Html interpreterHTML :: Reader AuthState Html
interpreterHTML = return $ do interpreterHTML = return $ do
H.input ! A.type_ "text" ! A.id "query" H.input ! A.type_ "text" ! A.id "query"
H.input ! A.type_ "button" ! A.id "submitquery" H.input ! A.type_ "button" ! A.id "submitquery" ! A.value "Submit Query"
H.div (H.toHtml ("Please enter a query" :: Text)) ! A.id "output" H.div (H.toHtml ("Please enter a query" :: Text)) ! A.id "output"


showForm :: AttributeValue -> FormHtml (HtmlM a) -> Html showForm :: AttributeValue -> FormHtml (HtmlM a) -> Html
Expand Down

0 comments on commit 571f58c

Please sign in to comment.