Questions tagged [fay]

Fay is a programming language that forms a proper subset of Haskell and which compiles to JavaScript.

Fay is a small programming language which has the following properties:

  • A proper syntactic and semantic subset of
  • Statically typed
  • Lazy
  • Pure by default
  • Compiles to
  • Has fundamental data types (Double, String, etc.) based upon what JS can support
  • Outputs minifier-aware code for small compressed size
  • Has a trivial foreign function interface to JavaScript
  • Typechecks using GHC
33 questions
13
votes
0 answers

Functional reactive programming — is Fay expressive enough?

So I'm doing a fairly involved javascript/html client with lots of ajax calls and other involvements of callback-ism. I'm entertaining the thought of using Fay for this purpose. I'm aware of Elm. Tried it and liked the FRP elements. Now I'm looking…
6
votes
1 answer

What is the correct way of including files/directories in Fay?

I am trying to compile haskell to JS using Fay with one directory after the --include option like so: fay --include src\Tmv src\Tmv\Client\Main.hs There is a SharedTypes.hs file in src\Tmv which defines a module Tmv.SharedTypes that is used in…
Jann Müller
  • 338
  • 1
  • 4
5
votes
1 answer

Size of fay generated file

I tried fay-jquery and the included sample test.hs file results in whooping 150 kb of js file. Even with closure compiling it is still 20 kb. I understand that it must carry a runtime, stdlib and jquery wrappers with it. I can tell fay not to…
Vagif Verdi
  • 4,816
  • 1
  • 26
  • 31
4
votes
2 answers

Require fay code from nodejs

Is it possible to require fay-compiled modules from other simple javascript files on the server side in nodejs? That would be just great. Maybe there is some option in compiler to produce commonjs-compatible modules?
AlexMost
  • 104
  • 7
3
votes
1 answer

Fay can't find fay-base

I want to use Fay with Yesod, but can't get Fay typechecking to work. Will appreciate any advice. $ stack build [ 9 of 11]…
Orfest
  • 135
  • 6
3
votes
1 answer

Haskell Fay sequence async calls

Recently, I decided to port some javascript code to Fay, so that I could guarantee type correctness, and so that I could handle async in a neat way (and also to experiment). I had built a few javascript objects whose only purpose was to synchronise…
user1158559
  • 1,954
  • 1
  • 18
  • 23
3
votes
1 answer

Using Fay in a cabal sandbox

I've just started using both cabal sandboxes and Fay. However, Fay seems unable to find the packages automatically, presumably as they are not in the 'global' cabal package database. I tried unsuccessfully to follow the advice on this wiki page,…
Daniel Buckmaster
  • 7,108
  • 6
  • 39
  • 57
3
votes
1 answer

Convert Char to ASCII code in Fay

Is there a way to convert values of type Char to their numerical ASCII codes in Fay? (The Haskell Prelude offers the function fromEnum and the equivalent function ord, but I don't see anything similar in the Fay Prelude.) The documentation for the…
Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67
3
votes
1 answer

your FFI declaration needs a type signature

Sometimes I face to weird issue, consider following examples: This compiles: renderFrame :: Frame -> Fay () renderFrame frame = do stack <- getStack if length stack > 0 then (do let e = head stack …
Geradlus_RU
  • 1,466
  • 2
  • 20
  • 37
3
votes
3 answers

Can't install Fay on Mac OS X Mavericks

I'm trying to cabal install fay fay-base. But it fails, here is the log: $ cabal install fay fay-base Resolving dependencies... Configuring pretty-show-1.6.3... Building pretty-show-1.6.3... Preprocessing library pretty-show-1.6.3... [1 of 6]…
Geradlus_RU
  • 1,466
  • 2
  • 20
  • 37
3
votes
1 answer

don't understand this liftM2 behaviour in Fay

I have this haskell code which behaves as expected: import Control.Monad getVal1 :: Maybe String getVal1 = Just "hello" getVal2 :: Maybe String getVal2 = Just "World" main = process >>= putStrLn process :: IO String process = case liftM2…
Emmanuel Touzery
  • 9,008
  • 3
  • 65
  • 81
3
votes
0 answers

multiple ajax queries in parallel with Fay

I'm looking to port JS code which runs two AJAX calls in parrallel but needs both to complete before operating. With JQuery you can do: $.when($.getJSON('/configVal'), $.getJSON('/configdesc')) .then(function(configByPluginResponse,…
Emmanuel Touzery
  • 9,008
  • 3
  • 65
  • 81
3
votes
1 answer

Fay JQuery work with array of elements

What is the preferred way, how to compute the number of elements selected by a selector? One way I can think of, is to call JQuery's size: size :: JQuery -> Fay Int size = ffi "%1['size']()" The other way is to get a list from a function call and…
ryskajakub
  • 6,351
  • 8
  • 45
  • 75
3
votes
1 answer

Persistent model types in Fay code

I'm using the Yesod scaffolded site (yesod 1.1.9.2) and spent a few hours yesterday wrapping my head around basic usage of Fay with Yesod. I think I now understand the intended workflow for using Fay to add a chunk of AJAX functionality to a page…
Christian Brink
  • 663
  • 4
  • 18
2
votes
0 answers

Serializing Maybe types

What is the correct type for serializing Maybe types? Given I have some data structure of Maybe type on the server and I serialize it with showToFay function, then it won't become one of the {"instance":"Nothing"} or…
ryskajakub
  • 6,351
  • 8
  • 45
  • 75
1
2 3