ghcjs

Using Overloaded Strings

痴心易碎 提交于 2020-01-01 04:45:09
问题 OverloadedStrings extension is really very useful, however it has some downsides. Consider the following function definition: someFunction :: ToJSSTring a => a -> IO () someFunction = js_function . toJSSTring In this case when if I want to pass a literal value I have to add a type signature explicitly when OverloadedStrings is enabled: someFunction ("This is plain string" :: String) someFunction ("And this one is Text" :: Data.Text.Text) The reason for this necessity is quite obvious, I

Installing reflex-dom likely to break ghcjs

老子叫甜甜 提交于 2019-12-23 21:41:28
问题 I am trying to install reflex and reflex-dom using cabal install I got the following error messages: $ cabal install reflex-dom ... cabal: The following packages are likely to be broken by the reinstalls: lens-4.15.1 ghcjs-0.2.0 free-4.12.4 kan-extensions-5.0.1 adjunctions-4.3 Use --force-reinstalls if you want to install anyway. ghcjs on GitHub is at 0.2.0 on the "master" branch and 0.2.1 on a branch called "dedupe". And I am also scared of breaking lens . Is there any way to install reflex

How to execute an action periodically in a GHCJS program?

允我心安 提交于 2019-12-23 09:27:25
问题 Should one use setInterval via Javascript, or use some more idiomatic solution based on threads? 回答1: If you don't care about the motivation, just scroll to my best solution runPeriodicallyConstantDrift below. If you prefer a simpler solution with worse results, then see runPeriodicallySmallDrift . My answer is not GHCJS specific, and has not been tested on GHCJS, only GHC, but it illustrates problems with the OP's naive solution. First Strawman Solution: runPeriodicallyBigDrift Here's my

how to code <h1> tags with ghcjs [closed]

一个人想着一个人 提交于 2019-12-11 06:54:41
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . I have found the ghcjs documentation very limited. Here is this basic HTML document. h1 { font-family: Helvetica; } p {font-family: Helvetica; color: blue; } <h1> Hello World </h1> <p> This is my test document. </p> Is ghcjs just a combinator, basically typing the HTML as an output string? Or does

Why do I get “ghcjs-boot: command not found”?

风格不统一 提交于 2019-12-11 03:37:54
问题 I've installed ghcjs by the command cabal install ./ghcjs ./ghcjs-prim And I get something like Updating documentation MyDir/Haskell/share/doc/x86_64-osx-ghc-7.8.3/index.html for my last line. But when I tried this command ghcjs-boot --dev I got -bash: ghcjs-boot: command not found What's the problem? 回答1: Rewriting my comment as an answer by request: Do you have ~/.cabal/bin in your PATH? 来源: https://stackoverflow.com/questions/29690766/why-do-i-get-ghcjs-boot-command-not-found

How to convert an `IO ()` to `JSVal` in GHCJS

a 夏天 提交于 2019-12-10 15:23:20
问题 i want to execute some effectful computation on a regular basis in a program compiled with GHCJS, but GHCJS.DOM.WindowTimers.setInterval wants a JSVal as parameter. Could anybody give me some pointers for turning my IO () into a JSVal ? Edit: I was able to match the types using GHCJS.Foreign.Callback.asyncCallback and GHCJS.Types.jsval , but i have eventually got a runtime error. Luite in the GHCJS channel suggested to use threads for this task, as Erik suggested in a comment here. This is

install ghcjs from stack

非 Y 不嫁゛ 提交于 2019-12-10 14:19:25
问题 I have GHC installed through stack ( so that stack ghc -- --version shows GHC-7.10.3 ) $ stack install ghcjs Run from outside a project, using implicit global project config Using resolver: lts-5.2 from implicit global project's config file: /home/john/.stack/global-project/stack.yaml The following target packages were not found: ghcjs Some resources suggest ghcjs is somewhat experimental (though in the further stages). Looking at http://docs.haskellstack.org/en/stable/ghcjs/ I thought maybe

How do you convert from an Unboxed Vector to a JS TypedArray on GHCJS?

笑着哭i 提交于 2019-12-07 10:22:28
问题 I have an element of type Data.Vector.Unboxed.Vector Word32 . I want to convert that to a native JS TypedArray (an Uint32Array , specifically). I'm aware of toJsArray and toJsValListOf , but both functions deal with lists, not vectors, and are inefficient. How can I convert an unboxed Vector directly to a JS TypedArray ? 回答1: I was able to solve this up to marshalling to an Int32Array instead of an Uint32Array ; probably someone who has actually known GHCJS for more than the one hour I've put

XhrRequest with reflex/reflex-dom

岁酱吖の 提交于 2019-12-05 23:51:41
问题 I want to perform a basic Ajax request, that's all. I use reflex for the frontend and Scotty for the backend. The Firefox Web Console tells me the request was a success and I see the expected result there. But the website switches from Just "default" to Nothing instead of Just "success!" . Here is a complete minimal example: import Reflex (holdDyn) import Reflex.Dom (button, el, mainWidget, display) import Reflex.Dom.Xhr (performRequestAsync, xhrRequest, decodeXhrResponse) import Reflex.Class

Creating a Behavior for a continuously measurable phenomenon

荒凉一梦 提交于 2019-12-05 16:24:56
问题 I would like to create a Behavior t a from an IO a , with the intended semantics that the IO action would be run every time the behavior is sample d: {- language FlexibleContexts #-} import Reflex.Dom import Control.Monad.Trans onDemand :: (MonadWidget t m, MonadIO (PullM t)) => IO a -> m (Behavior t a) I hoped I could do this by just executing the measurement in a pull : onDemand measure = return $ pull (liftIO measure) However, the resulting Behavior never changes after an initial measure