packages feed

fay 0.14.1.0 → 0.14.2.0

raw patch · 13 files changed

+37/−63 lines, 13 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Fay.Types: stateFilePath :: CompileState -> FilePath
+ Fay.Types: JsExpStmt :: JsExp -> JsStmt
- Fay.Types: CompileState :: Map ModuleName (Set QName) -> FilePath -> [(QName, [QName])] -> [(QName, [QName])] -> [(ModuleName, FilePath)] -> Integer -> Set Name -> ModuleScope -> ModuleName -> CompileState
+ Fay.Types: CompileState :: Map ModuleName (Set QName) -> [(QName, [QName])] -> [(QName, [QName])] -> [(ModuleName, FilePath)] -> Integer -> Set Name -> ModuleScope -> ModuleName -> CompileState
- Fay.Types: FfiFormatBadChars :: String -> CompileError
+ Fay.Types: FfiFormatBadChars :: SrcLoc -> String -> CompileError
- Fay.Types: FfiFormatIncompleteArg :: CompileError
+ Fay.Types: FfiFormatIncompleteArg :: SrcLoc -> CompileError
- Fay.Types: FfiFormatNoSuchArg :: Int -> CompileError
+ Fay.Types: FfiFormatNoSuchArg :: SrcLoc -> Int -> CompileError

Files

examples/canvaswater.hs view
@@ -50,11 +50,10 @@  -- | A DOM element. data Element-instance Foreign Element instance Eventable Element  -- | Add an event listener to an element.-addEventListener :: (Foreign a,Eventable a) => a -> String -> Fay () -> Bool -> Fay ()+addEventListener :: (Eventable a) => a -> String -> Fay () -> Bool -> Fay () addEventListener = ffi "%1['addEventListener'](%2,%3,%4)"  -- | Get an element by its ID.@@ -65,7 +64,6 @@ -- Images  data Image-instance Foreign Image instance Eventable Image  -- | Make a new image.@@ -81,7 +79,6 @@  -- | A canvas context. data Context-instance Foreign Context  -- | Get an element by its ID. getContext :: Element -> String -> Fay Context@@ -116,25 +113,24 @@  -- | A mutable reference like IORef. data Ref a-instance Foreign a => Foreign (Ref a)  -- | Make a new mutable reference.-newRef :: Foreign a => a -> Fay (Ref a)+newRef :: a -> Fay (Ref a) newRef = ffi "new Fay$$Ref(%1)"  -- | Replace the value in the mutable reference.-writeRef :: Foreign a => Ref a -> a -> Fay ()+writeRef :: Ref a -> a -> Fay () writeRef = ffi "Fay$$writeRef(%1,%2)"  -- | Get the referred value from the mutable value.-readRef :: Foreign a => Ref a -> Fay a+readRef :: Ref a -> Fay a readRef = ffi "Fay$$readRef(%1)"  -------------------------------------------------------------------------------- -- Misc  -- | Alert using window.alert.-alert :: Foreign a => a -> Fay ()+alert :: a -> Fay () alert = ffi "window['alert'](%1)"  -- | Alert using window.alert.
examples/console.hs view
@@ -5,6 +5,7 @@  main = putStrLn (showInt (fib 10)) +fib :: Int -> Int fib 0 = 0 fib 1 = 1 fib n = fib (n - 1) + fib (n - 2)
examples/data.hs view
@@ -13,6 +13,5 @@  data Foo = Foo { x :: Double, y :: String, z :: Foo } | Bar   deriving (Show)-instance Foreign Foo  main = print (show (Foo 123 "abc" Bar))
examples/dom.hs view
@@ -12,10 +12,9 @@ printBody :: Fay () printBody = do   result <- documentGetElements "body"-  print result+  putStrLn (showDOM result)  data Element-instance Foreign Element instance Show (Element)  documentGetElements :: String -> Fay [Element]@@ -23,3 +22,6 @@  addEventListener :: String -> Fay () -> Bool -> Fay () addEventListener = ffi "window['addEventListener'](%1,%2,%3)"++showDOM :: [Element] -> String+showDOM = ffi "%1"
examples/ref.hs view
@@ -17,13 +17,12 @@  data Ref a instance Show (Ref a)-instance Foreign a => Foreign (Ref a) -newRef :: Foreign a => a -> Fay (Ref a)+newRef :: a -> Fay (Ref a) newRef = ffi "new Fay$$Ref(%1)" -writeRef :: Foreign a => Ref a -> a -> Fay ()+writeRef :: Ref a -> a -> Fay () writeRef = ffi "Fay$$writeRef(%1,%2)" -readRef :: Foreign a => Ref a -> Fay a+readRef :: Ref a -> Fay a readRef = ffi "Fay$$readRef(%1)"
fay.cabal view
@@ -1,5 +1,5 @@ name:                fay-version:             0.14.1.0+version:             0.14.2.0 synopsis:            A compiler for Fay, a Haskell subset that compiles to JavaScript. description:         Fay is a proper subset of Haskell which is type-checked                      with GHC, and compiled to JavaScript. It is lazy, pure, has a Fay monad,@@ -21,39 +21,13 @@                      .                      /Release Notes/                      .-                     * Fix package resolving for nested dirs.-                     .-                     * Update test-cases for serialization.-                     .-                     * Fix fully specified parametrized type serialization.-                     .-                     * Full documentation.-                     .-                     * Change Language.Fay.* to Fay.*.-                     .-                     * Resolve packages using dataDir.-                     .-                     * Optimize FFI for embedded scripts.-                     .-                     * Option to not export built-ins.-                     .-                     * Flag to export only stdout.-                     .-                     * Output source of runtime rather than filename.-                     .-                     * Flag to output only the serialization dispatcher.-                     .-                     * Flag to exclude the serialization dispatcher.-                     .-                     * Flag to exclude stdlib from output.-                     .-                     * Flag to output naked decls (unwrapped).+                     * Recursively check package directories for .hs files.                      .-                     * Flag to print out the runtime JS source.+                     * Fix examples.                      .-                     * Flag to not export runtime.+                     * Show line numbers in FFI errors.                      .-                     * Remove Language.Fay.Stdlib/Prelude, superseded by fay-base+                     * Support () in pattern matches.                      .                      See full history at: <https://github.com/faylang/fay/commits> homepage:            http://fay-lang.org/
src/Fay.hs view
@@ -167,9 +167,9 @@   InvalidDoBlock -> "invalid `do' block"   RecursiveDoUnsupported -> "recursive `do' isn't supported"   FfiNeedsTypeSig d -> "your FFI declaration needs a type signature: " ++ prettyPrint d-  FfiFormatBadChars cs -> "invalid characters for FFI format string: " ++ show cs-  FfiFormatNoSuchArg i -> "no such argument in FFI format string: " ++ show i-  FfiFormatIncompleteArg -> "incomplete `%' syntax in FFI format string"+  FfiFormatBadChars      srcloc cs -> printSrcLoc srcloc ++ ": invalid characters for FFI format string: " ++ show cs+  FfiFormatNoSuchArg     srcloc i  -> printSrcLoc srcloc ++ ": no such argument in FFI format string: " ++ show i+  FfiFormatIncompleteArg srcloc    -> printSrcLoc srcloc ++ ": incomplete `%' syntax in FFI format string"   FfiFormatInvalidJavaScript srcloc code err ->     printSrcLoc srcloc ++ ":" ++     "\ninvalid JavaScript code in FFI format string:\n"
src/Fay/Compiler.hs view
@@ -55,7 +55,7 @@   cs <- defaultCompileState   rs <- defaultCompileReader config   runCompile rs-             (cs { stateFilePath = filepath })+             cs              (parseResult (throwError . uncurry ParseError)                           (fmap (\x -> execState (runPrinter (printJS x)) printConfig) . with)                           (parseFay filepath from))
src/Fay/Compiler/Defaults.hs view
@@ -36,7 +36,6 @@   , stateRecords = []   , stateImported = [("Fay.Types",types)]   , stateNameDepth = 1-  , stateFilePath = "<unknown>"   , stateLocalScope = S.empty   , stateModuleScope = def   }
src/Fay/Compiler/FFI.hs view
@@ -39,7 +39,7 @@            -> Type   -- ^ Type signature.            -> Compile [JsStmt] compileFFI srcloc name formatstr sig = do-  inner <- formatFFI formatstr (zip params funcFundamentalTypes)+  inner <- formatFFI srcloc formatstr (zip params funcFundamentalTypes)   case JS.parse JS.parseExpression (prettyPrint name) (printJSString (wrapReturn inner)) of     Left err -> throwError (FfiFormatInvalidJavaScript srcloc inner (show err))     Right exp  -> do@@ -268,10 +268,11 @@   _              -> 0  -- | Format the FFI format string with the given arguments.-formatFFI :: String                      -- ^ The format string.+formatFFI :: SrcLoc                     -- ^ Location of the original FFI decl.+          -> String                     -- ^ The format string.           -> [(JsName,FundamentalType)] -- ^ Arguments.-          -> Compile String              -- ^ The JS code.-formatFFI formatstr args = go formatstr where+          -> Compile String             -- ^ The JS code.+formatFFI srcloc formatstr args = go formatstr where   go ('%':'*':xs) = do     these <- mapM inject (zipWith const [1..] args)     rest <- go xs@@ -279,10 +280,10 @@   go ('%':'%':xs) = do     rest <- go xs     return ('%' : rest)-  go ['%'] = throwError FfiFormatIncompleteArg+  go ['%'] = throwError (FfiFormatIncompleteArg srcloc)   go ('%':(span isDigit -> (op,xs))) =     case readMay op of-     Nothing -> throwError (FfiFormatBadChars op)+     Nothing -> throwError (FfiFormatBadChars srcloc op)      Just n -> do        this <- inject n        rest <- go xs@@ -293,7 +294,7 @@    inject n =     case listToMaybe (drop (n-1) args) of-      Nothing -> throwError (FfiFormatNoSuchArg n)+      Nothing -> throwError (FfiFormatNoSuchArg srcloc n)       Just (arg,typ) -> do         return (printJSString (fayToJs SerializeAnywhere typ (JsName arg))) 
src/Fay/Compiler/Pattern.hs view
@@ -107,6 +107,7 @@   let boolIf b = return [JsIf (JsEq forcedExp (JsLit (JsBool b))) body []]   case cons of     -- Special-casing on the booleans.+    Special UnitCon -> return (JsExpStmt forcedExp : body)     "True" -> boolIf True     "False" -> boolIf False     -- Everything else, generic:
src/Fay/Compiler/Print.hs view
@@ -90,6 +90,8 @@  -- | Print a single statement. instance Printable JsStmt where+  printJS (JsExpStmt e) =+    printJS e +> ";" +> newline   printJS (JsBlock stmts) =     "{ " +> stmts +> "}"   printJS (JsVar name expr) =
src/Fay/Types.hs view
@@ -82,7 +82,6 @@ -- | State of the compiler. data CompileState = CompileState   { _stateExports     :: Map ModuleName (Set QName) -- ^ Collects exports from modules-  , stateFilePath     :: FilePath                   -- ^ Current file path. TODO: Used?   , stateRecordTypes  :: [(QName,[QName])]          -- ^ Map types to constructors   , stateRecords      :: [(QName,[QName])]          -- ^ Map constructors to fields   , stateImported     :: [(ModuleName,FilePath)]    -- ^ Map of all imported modules and their source locations.@@ -207,9 +206,9 @@   | RecursiveDoUnsupported   | Couldn'tFindImport ModuleName [FilePath]   | FfiNeedsTypeSig Decl-  | FfiFormatBadChars String-  | FfiFormatNoSuchArg Int-  | FfiFormatIncompleteArg+  | FfiFormatBadChars SrcLoc String+  | FfiFormatNoSuchArg SrcLoc Int+  | FfiFormatIncompleteArg SrcLoc   | FfiFormatInvalidJavaScript SrcLoc String String   | UnableResolveUnqualified Name   | UnableResolveQualified QName@@ -236,6 +235,7 @@   | JsSetPropExtern JsName JsName JsExp   | JsContinue   | JsBlock [JsStmt]+  | JsExpStmt JsExp   deriving (Show,Eq)  -- | Expression type.