Skip to content

Commit ae3a309

Browse files
committed
editor: Reflex skeleton
1 parent b764227 commit ae3a309

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

language-powerquery-editor/language-powerquery-editor.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ library
2323
-- other-extensions:
2424
build-depends: base
2525
, lens
26+
, uniplate
2627
, aeson
2728
, bytestring
2829
, text
30+
, time
2931
, language-powerquery-ast
3032
, language-powerquery
3133
, jsaddle

language-powerquery-editor/src/Language/PowerQuery/Editor/CodeMirror.hs

Whitespace-only changes.
Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,56 @@
11
{-# LANGUAGE PackageImports #-}
2+
{-# LANGUAGE OverloadedStrings #-}
3+
{-# LANGUAGE ScopedTypeVariables #-}
4+
{-# LANGUAGE RankNTypes #-}
25
module Language.PowerQuery.Editor.Editor where
36

7+
import "base" Control.Monad.IO.Class (liftIO)
8+
import "uniplate" Data.Generics.Uniplate.Data (universeBi)
9+
import "aeson" Data.Aeson (Value(Null), toJSON)
10+
import "text" Data.Text (Text, unpack)
11+
import "time" Data.Time.Clock (getCurrentTime)
12+
import "reflex" Reflex
13+
import "reflex-dom" Reflex.Dom hiding (Value)
414
import "language-powerquery-ast" Language.PowerQuery.AST
15+
import "language-powerquery" Language.PowerQuery
516

6-
main :: IO ()
7-
main = do
8-
return ()
17+
codemirror :: forall t m. (MonadWidget t m)
18+
=> ()
19+
-> m (Event t Text)
20+
codemirror _ = return undefined
21+
22+
jsoneditor :: forall t m. (MonadWidget t m)
23+
=> Dynamic t Value
24+
-> m ()
25+
jsoneditor _ = return ()
26+
27+
28+
body :: forall t m. (MonadWidget t m)
29+
=> m ()
30+
body = do
31+
-- code editor
32+
(scriptE' :: Event t Text) <- codemirror ()
33+
scriptE <- debounce 1 scriptE' -- rate limit change events from editor
34+
35+
-- Tokens
36+
let lexE = (lexer . unpack) <$> scriptE
37+
let (tokensE :: Event t [Token]) = filterRight lexE
38+
let (lexErrorE :: Event t String) = filterLeft lexE
39+
40+
-- AST
41+
let (astE :: Event t (Document Annotation)) = parseDocument <$> tokensE
42+
let (variablesE :: Event t [Variable Annotation]) = variables <$> astE
43+
44+
-- JSON viewer
45+
let (jsonE :: Event t Value) = toJSON <$> astE
46+
jsonD <- holdDyn Null jsonE
47+
jsoneditor jsonD
48+
49+
where
50+
variables :: (Document Annotation -> [Variable Annotation])
51+
variables = universeBi
52+
53+
54+
55+
main = mainWidget $ do
56+
body

language-powerquery-editor/src/Language/PowerQuery/Editor/JSONEditor.hs

Whitespace-only changes.

0 commit comments

Comments
 (0)