-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Jmonkey is very restricted but handy EDSL for JavaScript. -- -- Please see the README on GitHub at -- https://github.com/opyapeus/jmonkey#readme @package jmonkey @version 0.1.0.1 -- | JMonkey data types. module JMonkey.Data -- | Represents id and class. data Selector Id :: String -> Selector Class :: String -> Selector -- | Represents javascript element(s). data Target Elem :: String -> Target Elems :: String -> Target -- | Comparision operator. data CompOp Equal :: CompOp Grater :: CompOp Less :: CompOp -- | Repetition. data Repeat Once :: Repeat Endless :: Repeat -- | Document element. doc :: Target -- | Window element. win :: Target instance GHC.Classes.Eq JMonkey.Data.Repeat instance GHC.Show.Show JMonkey.Data.Repeat instance GHC.Classes.Eq JMonkey.Data.CompOp instance GHC.Show.Show JMonkey.Data.CompOp instance GHC.Classes.Eq JMonkey.Data.Target instance GHC.Show.Show JMonkey.Data.Target instance GHC.Classes.Eq JMonkey.Data.Selector instance GHC.Show.Show JMonkey.Data.Selector -- | JMonkey actions. module JMonkey.Action -- | Empty JMonkey monad. type JMonkey = JMonkeyM () -- | JMonkey monad designed with free monad. type JMonkeyM = Free Action -- | JMonkey action AST. data Action n Log :: String -> n -> Action n Alert :: String -> n -> Action n Select :: Selector -> (Target -> n) -> Action n Add :: Target -> Selector -> n -> Action n Remove :: Target -> Selector -> n -> Action n On :: String -> Target -> JMonkey -> n -> Action n OnTime :: Repeat -> Int -> JMonkey -> n -> Action n If :: Cond -> JMonkey -> JMonkey -> n -> Action n -- | JMonkey conditions. These mean boolean value. data Cond -- | if all the target have the selector Possess :: Target -> Selector -> Cond -- | if window.pageYOffset satisfies with given comparision operator and -- threshold value YOffset :: CompOp -> Double -> Cond -- | Show console log. putLog :: String -> JMonkey -- | Show alert. alert :: String -> JMonkey -- | Select target by given selector. select :: Selector -> JMonkeyM Target -- | Add class or id to the target. -- -- For multiple selectors -- --
-- f :: Target -> [Selector] -> JMonkey -- f t = mapM_ (add t) --add :: Target -> Selector -> JMonkey -- | Add class or id to the targets. -- -- For multiple selectors -- --
-- f :: [Target] -> [Selector] -> JMonkey -- f ts = mapM_ (adds ts) --adds :: [Target] -> Selector -> JMonkey -- | Remove class or id from the target. remove :: Target -> Selector -> JMonkey -- | Remove class or id from the targets. removes :: [Target] -> Selector -> JMonkey -- | Make event. on :: String -> Target -> JMonkey -> JMonkey -- | Same as on "click". onClick :: Target -> JMonkey -> JMonkey -- | Same as on "scroll". onScroll :: Target -> JMonkey -> JMonkey -- | Same as on "change". onChange :: Target -> JMonkey -> JMonkey -- | Make time triggered event. onTime :: Repeat -> Int -> JMonkey -> JMonkey -- | Make conditional action. ifel :: Cond -> JMonkey -> JMonkey -> JMonkey -- | Only true conditional action of ifel ifThen :: Cond -> JMonkey -> JMonkey -- | Only false conditional action of ifel elThen :: Cond -> JMonkey -> JMonkey instance GHC.Base.Functor JMonkey.Action.Action -- | JMonkey interpreter using jmacro backend. module JMonkey.Interpreter -- | Interpret to javascript string. interpretString :: JMonkey -> String -- | Interpret to jmacro statement. interpretJStat :: JMonkey -> JStat -- | Jmonkey is very restricted but handy EDSL for javascript. -- -- It's backend uses free for designing DSL and jmacro for -- interpreter. -- -- Here is some examples. -- -- Click btn element then add "clicked" class to target elements. -- --
-- btn <- select (Id "btn") -- target <- select (Class "target") -- onClick btn $ add target (Class "clicked") ---- -- If target element(s) have "hide" class then remove, otherwise add -- "hide" class. -- --
-- ifel (Having target (Class "hide")) -- (remove target (Class "hide")) -- (add target (Class "hide")) ---- -- Once you define some actions like aboves, you can get javascript -- string easily by interpretString. module JMonkey