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
2
votes
1 answer

Haskell cabal compile .js during build

Let's say I'm building a web application with haskell as both server-side and client-side code. During the build phase, I want to compile server-side code with ghc and client-side code with some haskell to js transpiler. The haskell transpiler…
ryskajakub
  • 6,351
  • 8
  • 45
  • 75
2
votes
0 answers

Yesod Fay - Uncaught ReferenceError: XXX is not defined

I'm trying to set up Yesod, while running Fay for the frontend of my site. It's mostly working as I'd expect, as in any Fay I write runs. The problem is I'm getting an Uncaught ReferenceError in the generated JS. Here is a short version of the JS in…
LeeG
  • 265
  • 1
  • 4
  • 11
2
votes
1 answer

Fay, render loop and mouse events

Prelude. I'm new to Haskell and functional programming at all, but I can't help coding in Haskell, because it' so exiciting! Thus, my question could be very simple and/or trivial. I'm still reading "Learn You a Haskell for Great Good", and Monads…
Geradlus_RU
  • 1,466
  • 2
  • 20
  • 37
2
votes
1 answer

Haskell fay install failed

I'm trying to install fay but src compiling fails with $ cabal install fay ... Preprocessing executable 'fay' for fay-0.10.1.0... [ 1 of 14] Compiling Data.List.Extra ( src/Data/List/Extra.hs, dist/build/fay/fay- tmp/Data/List/Extra.o ) [ 2 of 14]…
akegalj
  • 379
  • 2
  • 10
1
vote
0 answers

Data.Tree for Fay

I am using Data.Tree.unfoldTree in a Fay script but it cannot be compiled and it is not included in fay-base. Is there a way to import from Data.Tree?
Randomize
  • 8,651
  • 18
  • 78
  • 133
1
vote
1 answer

How do I install fay?

I'm running ubuntu 13.10 and I'm having trouble installing fay. I installed haskell using sudo apt-get install haskell-platform . I try cabal install fay and I receive the following message: $ cabal install fay Resolving dependencies... Configuring…
aled1027
  • 1,326
  • 2
  • 13
  • 17
1
vote
1 answer

Connect legacy Haskell code and Fay code

I have some Haskell code, and would like a Fay script to be able to access it. The problem is the Haskell code uses monads. Fay doesn't support arbitrary monads. How do I get my Haskell code to work with Fay? Namely, the Fay script needs to be able…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
1
vote
1 answer

Fay: unable to resolve qualified names ffi?

I have installed: fay-0.19.0.1 fay-base-0.19 And I'm trying to compile -- test.hs module Main where import FFI main = ffi "alert('hello world');" with fay test.hs And getting fay: unable to resolve qualified names ffi Note that I am able to…
Justin L.
  • 13,510
  • 5
  • 48
  • 83
1
vote
1 answer

How to obtain "this" object in Fay?

Given this HTML:
a
b
I'm trying do make a handler depend on the value of "this", like in the following JavaScript code: $(document).ready(function() { …
kxmh42
  • 3,121
  • 1
  • 25
  • 15
1
vote
1 answer

Compiling a library using Fay: hidden package 'base'

I'm having trouble compiling a working Haskell library to JavaScript using Fay. I believe I've successfully installed Fay using cabal-dev, and set the HASKELL_PACKAGE_SANDBOX environment. When I attempt to compile, I get the following: …
Neil
  • 345
  • 1
  • 11
1
vote
2 answers

fay: possible to sort strings?

I can't seem to succeed in sorting strings with Fay. I realize that it's connected to the fact that Fay doesn't support type classes, but that seems like a real pain if that doesn't work... import Prelude main :: Fay () main = print $ sort ["a",…
Emmanuel Touzery
  • 9,008
  • 3
  • 65
  • 81
1
vote
1 answer

Fay: include another Fay file?

I have one Fay file which is the heart of my program, however I need some helpers for my logic, for instance a method to replace substrings. From what I understand, if I need such methods which are offered by many Haskell libraries from Hackage…
Emmanuel Touzery
  • 9,008
  • 3
  • 65
  • 81
0
votes
0 answers

Fay: how to show a value and use this string in JS?

I'm mixing old JS and new Fay-generated JS, and I'm trying to get a string representation of some data from Fay. I defined jshow :: Bool -> String jshow d = show d It's not just a Bool in the real code, but the type doesn't change the error. This…
S_FLUID
  • 63
  • 6
0
votes
1 answer

Derive Monad from Fay newtype in order to enable do notation

I want to create a different classes of side-effecty functions, so I can mark some of the side-effects as safer than other ones. I'd like to create a newtype over the Fay side-effect monad and use it in the do notation, so I declare it like…
ryskajakub
  • 6,351
  • 8
  • 45
  • 75
0
votes
1 answer

Passing records to ffi

When I pass a record to javascript, it works: data Record = Record { elem :: String } doSomethingForeign :: Record -> Fay () doSomethingForeign = ffi " callJsFun(%1) " But when the function is not monomorphical, the record is not evaluated, one…
ryskajakub
  • 6,351
  • 8
  • 45
  • 75