Permalink
Browse files

Reformat all .hs files with stylish-haskell and whitespace cleanup.

  • Loading branch information...
1 parent 2ef6404 commit 8eae041b943ff9f4920bb8655d3e9624cca2f0c4 @chrisdone chrisdone committed Jul 30, 2012
View
@@ -2,8 +2,8 @@
module Tailrecursive where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
benchmarks = 5
@@ -53,4 +53,4 @@ max x y = if x > y then x else y
maximum (x:xs) = foldl max x xs
minimum (x:xs) = foldl min x xs
-square x = x * x
+square x = x * x
View
@@ -1,12 +1,12 @@
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
-- | The home page script:
---
+--
-- 1) Make sure that the language samples are highlighted.
-- 2) Add a show/hide button for the JS output on all samples.
-- 3) For code samples that are too large, hide them.
---
+--
-- Because dogfood. This is not necessarily a good example, indeed, it
-- may very well be a very bad example of how to write client
-- code. But that's the point, really. Even the quick scripts that
@@ -15,8 +15,8 @@
module Home (main) where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
-- | Main entry point.
main :: Fay ()
View
@@ -8,4 +8,4 @@ math = Math sqrt
(\x -> x * x)
(\x -> x * square math x)
-rootroot = root math (root math 5)
+rootroot = root math (root math 5)
View
@@ -1,3 +1,5 @@
+{-# LANGUAGE EmptyDataDecls #-}
+
main = do
result <- documentGetElements "body"
print result
View
@@ -1,4 +1,4 @@
--- Tail-recursive functions will use
+-- Tail-recursive functions will use
-- constant stack space
sum 0 acc = acc
sum n acc = sum (n - 1) (acc + n)
View
@@ -2,8 +2,8 @@
module Alert where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
main :: Fay ()
main = alert "Hello, World!"
View
@@ -1,15 +1,15 @@
-- | Compile with: dist/build/fay/fay -autorun examples/canvaswater.hs
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
-- | A demonstration of Fay using the canvas element to display a
-- simple effect.
module CanvasWater (main) where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
-- | Main entry point.
main :: Fay ()
@@ -93,8 +93,8 @@ drawImage = ffi "%1['drawImage'](%2,%3,%4)" FayNone
-- | Draw an image onto a canvas rendering context.
--
--- Nine arguments: the element, source (x,y) coordinates, source width and
--- height (for cropping), destination (x,y) coordinates, and destination width
+-- Nine arguments: the element, source (x,y) coordinates, source width and
+-- height (for cropping), destination (x,y) coordinates, and destination width
-- and height (resize).
--
-- context.drawImage(img_elem, sx, sy, sw, sh, dx, dy, dw, dh);
View
@@ -2,8 +2,8 @@
module Console where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
main = print "Hello, World!"
View
@@ -1,5 +1,5 @@
-- Generate Show value.
---
+--
-- $ fay -autorun examples/data.hs
-- $ node examples/data.js
-- (Foo { x = 123, y = "abc", z = (Bar) })
@@ -8,8 +8,8 @@
module Data where
-import Language.Fay.Prelude
-import Language.Fay.FFI
+import Language.Fay.FFI
+import Language.Fay.Prelude
data Foo = Foo { x :: Double, y :: String, z :: Foo } | Bar
deriving (Show)
@@ -18,4 +18,4 @@ instance Foreign Foo
main = print (show (Foo 123 "abc" Bar))
print :: String -> Fay ()
-print = ffi "console.log(%1)" FayNone
+print = ffi "console.log(%1)" FayNone
View
@@ -1,10 +1,10 @@
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Dom where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
main :: Fay ()
main = addEventListener "load" printBody False
@@ -24,4 +24,4 @@ documentGetElements :: String -> Fay [Element]
documentGetElements = ffi "document.getElementsByTagName(%1)" FayArray
addEventListener :: String -> Fay () -> Bool -> Fay ()
-addEventListener = ffi "window['addEventListener'](%1,%2,%3)" FayNone
+addEventListener = ffi "window['addEventListener'](%1,%2,%3)" FayNone
View
@@ -1,12 +1,12 @@
-- | Simple example interfacing with node.
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Test where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
data Sys
instance Foreign Sys
View
@@ -1,10 +1,10 @@
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Dom where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
main :: Fay ()
main = addEventListener "load" updateBody False
@@ -24,7 +24,7 @@ alert' = ffi "console['log'](%1)" FayNone
-- | Alert using window.alert.
alert :: Foreign a => a -> Fay ()
alert = ffi "console['log'](%1)" FayNone
-
+
addEventListener :: String -> Fay () -> Bool -> Fay ()
addEventListener = ffi "window['addEventListener'](%1,%2,%3)" FayNone
View
@@ -1,12 +1,12 @@
-- | Mutable references.
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Ref where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
main :: Fay ()
main = do
@@ -8,8 +8,8 @@
module Tailrecursive where
-import Language.Fay.FFI
-import Language.Fay.Prelude
+import Language.Fay.FFI
+import Language.Fay.Prelude
main = do
benchmark
View
@@ -17,4 +17,4 @@ show = ffi "Fay$$encodeShow(%1)" FayString
-- There is only Double in JS.
fromInteger x = x
-fromRational x = x
+fromRational x = x
View
@@ -108,7 +108,7 @@ function Fay$$serialize(type,obj){
str += obj.car;
obj = _(obj.cdr);
}
- return str;
+ return str;
} else if(type == "FunctionType" || typeof obj == 'function'){
return function(){
var out = obj;
@@ -119,20 +119,20 @@ function Fay$$serialize(type,obj){
out = out(arguments[i]);
}
return _(out,true);
- };
+ };
} else if(type == "ListType" || (obj instanceof Fay$$Cons)){
var arr = [];
while(obj instanceof Fay$$Cons) {
arr.push(Fay$$serialize(null,obj.car));
obj = _(obj.cdr);
}
- return arr;
+ return arr;
} // else if(type == "BoolType || obj == _(True) || obj == _(False)) {
// return obj == _(True);
- // }
+ // }
else {
return obj;
- }
+ }
}
}
@@ -360,4 +360,3 @@ function Fay$$date(str){
/*******************************************************************************
* Application code.
*/
-
@@ -1,6 +1,6 @@
module Control.Monad.Extra where
-import Data.Maybe
+import Data.Maybe
ig :: (Monad m) => m a -> m ()
ig m = m >> return ()
View
@@ -1,6 +1,6 @@
module Control.Monad.IO where
-import Control.Monad.Trans
+import Control.Monad.Trans
io :: MonadIO m => IO a -> m a
io = liftIO
View
@@ -1,28 +1,28 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE CPP #-}
{-# OPTIONS -fno-warn-missing-signatures -fno-warn-unused-do-bind #-}
-- | Generate documentation for Fay.
module Main where
-import Language.Fay (compileViaStr,compileModule)
-import Language.Fay.Compiler (compileFromTo)
+import Language.Fay (compileModule, compileViaStr)
+import Language.Fay.Compiler (compileFromTo)
import Control.Exception
import Control.Monad
-import qualified Data.ByteString.Lazy as L
+import qualified Data.ByteString.Lazy as L
import Data.Char
import Data.Default
-import Data.List (isSuffixOf,sort)
+import Data.List (isSuffixOf, sort)
import Data.Time
-import Prelude hiding (head,div)
+import Prelude hiding (div, head)
import System.Directory
import System.FilePath
import Text.Blaze.Extra
-import Text.Blaze.Html5 as H hiding (contents,map,style)
+import Text.Blaze.Html5 as H hiding (contents, map, style)
import Text.Blaze.Html5.Attributes as A hiding (title)
-import Text.Blaze.Renderer.Utf8 (renderMarkup)
+import Text.Blaze.Renderer.Utf8 (renderMarkup)
-- | Main entry point.
main :: IO ()
@@ -31,7 +31,7 @@ main = do
generate >>= L.writeFile file
generateJs
putStrLn $ "Documentation file written to " ++ file
-
+
generate = do
sources <- mapM readFile examples
javascripts <- mapM compile examples
@@ -40,7 +40,7 @@ generate = do
return $ renderMarkup $ page now
analytics
(zip3 (map titlize examples) sources javascripts)
-
+
where compile file = do
contents <- readFile file
putStrLn $ "Compiling " ++ file ++ " ..."
@@ -58,7 +58,7 @@ generate = do
generateJs = do
putStrLn $ "Compiling " ++ inp ++ " to " ++ out ++ " ..."
compileFromTo def True inp out
-
+
where docs = ("docs" </>)
inp = (docs "home.hs")
out = (docs "home.js")
@@ -91,7 +91,7 @@ thebody now analytics examples = do
thefooter now
preEscapedToMarkup analytics
-fork =
+fork =
a ! href "https://github.com/chrisdone/fay" $
img ! style "position: absolute; top: 0; right: 0; border: 0;"
! src "https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
@@ -172,7 +172,7 @@ thejsproblem = do
" The depths to which JavaScript sucks is well-documented and well-understood. Its main faults are: its lack of module system, weak-typing, verbose function syntax, late binding, which has led to the creation of various static analysis tools to alleviate this language flaw, but with limited success (there is even a static type checker), finicky equality/automatic conversion, this behaviour, and lack of static types."
li $ do strong "We need JavaScript:"
" Using it for what it is good for, i.e. providing a platform for browser development, but not using the language per se, is therefore desirable, and many are working to achieve this, in varying forms. There are various ways to do it, but we ought to opt for compiling an existing language, Haskell, to JavaScript, because we do not have time to learn or teach other people a new language, garner a new library set and a new type checker and all that Haskell implementations provide."
- p $ a ! href "http://www.haskell.org/haskellwiki/The_JavaScript_Problem" $
+ p $ a ! href "http://www.haskell.org/haskellwiki/The_JavaScript_Problem" $
"See here for more elaboration »"
thecomparisons = do
Oops, something went wrong.

0 comments on commit 8eae041

Please sign in to comment.