yesod-fay 0.6.1 → 0.7.0
raw patch · 4 files changed
+60/−85 lines, 4 filesdep +fay-domdep −fay-textdep ~fayPVP ok
version bump matches the API change (PVP)
Dependencies added: fay-dom
Dependencies removed: fay-text
Dependency ranges changed: fay
API changes (from Hackage documentation)
- Language.Fay.Yesod: Returns :: Returns a
- Language.Fay.Yesod: ajaxCommand :: Automatic command -> (Automatic a -> Fay ()) -> Fay ()
- Language.Fay.Yesod: ajaxCommandWithErrorHandling :: Automatic command -> (Automatic a -> Fay ()) -> (Fay ()) -> Fay ()
- Language.Fay.Yesod: call :: (Returns a -> command) -> (a -> Fay ()) -> Fay ()
- Language.Fay.Yesod: callWithErrorHandling :: (Returns a -> command) -> (a -> Fay ()) -> (Fay ()) -> Fay ()
- Language.Fay.Yesod: data Returns a
- Language.Fay.Yesod: fromString :: String -> Text
- Language.Fay.Yesod: instance Data a => Data (Returns a)
- Language.Fay.Yesod: instance Eq (Returns a)
- Language.Fay.Yesod: instance Read (Returns a)
- Language.Fay.Yesod: instance Show (Returns a)
- Language.Fay.Yesod: instance Typeable1 Returns
- Language.Fay.Yesod: toString :: Text -> String
- Language.Fay.Yesod: type Text = Text
- Yesod.Fay: instance YesodFay master => YesodSubDispatch FaySite (HandlerT master IO)
- Yesod.Fay: yfsExternal :: YesodFaySettings -> Maybe (FilePath, Exp)
- Yesod.Fay: yfsModuleName :: YesodFaySettings -> String
- Yesod.Fay: yfsPackages :: YesodFaySettings -> [String]
- Yesod.Fay: yfsPostProcess :: YesodFaySettings -> String -> IO String
- Yesod.Fay: yfsRequireJQuery :: YesodFaySettings -> Bool
- Yesod.Fay: yfsSeparateRuntime :: YesodFaySettings -> Maybe (FilePath, Exp)
- Yesod.Fay: yfsTypecheckDevel :: YesodFaySettings -> Bool
+ Fay.Yesod: Returns :: Returns a
+ Fay.Yesod: ajaxCommand :: Automatic command -> (Automatic a -> Fay ()) -> Fay ()
+ Fay.Yesod: ajaxCommandWithErrorHandling :: Automatic command -> (Automatic a -> Fay ()) -> (Fay ()) -> Fay ()
+ Fay.Yesod: call :: (Returns a -> command) -> (a -> Fay ()) -> Fay ()
+ Fay.Yesod: callWithErrorHandling :: (Returns a -> command) -> (a -> Fay ()) -> (Fay ()) -> Fay ()
+ Fay.Yesod: data Returns a
+ Fay.Yesod: instance Data.Data.Data a => Data.Data.Data (Fay.Yesod.Returns a)
+ Fay.Yesod: instance GHC.Classes.Eq (Fay.Yesod.Returns a)
+ Fay.Yesod: instance GHC.Read.Read (Fay.Yesod.Returns a)
+ Fay.Yesod: instance GHC.Show.Show (Fay.Yesod.Returns a)
+ Yesod.Fay: [yfsExternal] :: YesodFaySettings -> Maybe (FilePath, Exp)
+ Yesod.Fay: [yfsModuleName] :: YesodFaySettings -> String
+ Yesod.Fay: [yfsPackages] :: YesodFaySettings -> [String]
+ Yesod.Fay: [yfsPostProcess] :: YesodFaySettings -> String -> IO String
+ Yesod.Fay: [yfsRequireJQuery] :: YesodFaySettings -> Bool
+ Yesod.Fay: [yfsSeparateRuntime] :: YesodFaySettings -> Maybe (FilePath, Exp)
+ Yesod.Fay: [yfsTypecheckDevel] :: YesodFaySettings -> Bool
+ Yesod.Fay: instance Yesod.Fay.YesodFay master => Yesod.Core.Class.Dispatch.YesodSubDispatch Yesod.Fay.Data.FaySite (Yesod.Core.Types.HandlerT master GHC.Types.IO)
- Yesod.Fay: fayEncode :: (YesodFay master, Show a, Data a) => master -> a -> Maybe Value
+ Yesod.Fay: fayEncode :: (YesodFay master, Data a) => master -> a -> Maybe Value
- Yesod.Fay: type CommandHandler master = forall s. (forall a. (Show a, Data a) => Returns a -> a -> HandlerT master IO s) -> Value -> HandlerT master IO s
+ Yesod.Fay: type CommandHandler master = forall s. (forall a. (Data a) => Returns a -> a -> HandlerT master IO s) -> Value -> HandlerT master IO s
Files
- Fay/Yesod.hs +47/−0
- Language/Fay/Yesod.hs +0/−73
- Yesod/Fay.hs +9/−8
- yesod-fay.cabal +4/−4
+ Fay/Yesod.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE CPP #-}+-- | Module to be shared between server and client.+--+-- This module must be valid for both GHC and Fay.+module Fay.Yesod where++import Prelude+#ifdef FAY+import FFI+#else+import Fay.FFI+#endif+import Data.Data++-- | A proxy type for specifying what type a command should return. The final+-- field for each data constructor in a command datatype should be @Returns@.+data Returns a = Returns+ deriving (Eq, Show, Read, Data, Typeable)++-- | Call a command.+call :: (Returns a -> command)+ -> (a -> Fay ()) -- ^ Success Handler+ -> Fay ()+call f g = ajaxCommand (f Returns) g++-- ! Call a command, handling errors as well+callWithErrorHandling+ :: (Returns a -> command)+ -> (a -> Fay ()) -- ^ Success Handler+ -> (Fay ()) -- ^ Failure Handler+ -> Fay ()+callWithErrorHandling f g h = ajaxCommandWithErrorHandling (f Returns) g h++-- | Run the AJAX command.+ajaxCommand :: Automatic command+ -> (Automatic a -> Fay ()) -- ^ Success Handler+ -> Fay ()+ajaxCommand = ffi "jQuery['ajax']({ url: window['yesodFayCommandPath'], type: 'POST', data: { json: JSON.stringify(%1) }, dataType: 'json', success : %2})"++-- | Run the AJAX command, handling errors as well+ajaxCommandWithErrorHandling+ :: Automatic command+ -> (Automatic a -> Fay ()) -- ^ Success Handler+ -> (Fay ()) -- ^ Failure Handler+ -> Fay ()+ajaxCommandWithErrorHandling = ffi "jQuery['ajax']({ url: window['yesodFayCommandPath'], type: 'POST', data: { json: JSON.stringify(%1) }, dataType: 'json', success : %2, error: %3})"
− Language/Fay/Yesod.hs
@@ -1,73 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE CPP #-}--- | Module to be shared between server and client.------ This module must be valid for both GHC and Fay.-module Language.Fay.Yesod where--import Prelude-#ifdef FAY-import FFI-#else-import Fay.FFI-#endif-import Data.Data--#ifdef FAY--data Text = Text- deriving (Show, Read, Eq, Typeable, Data)--fromString :: String -> Text-fromString = ffi "%1"--toString :: Text -> String-toString = ffi "%1"--#else--import qualified Data.Text as T--type Text = T.Text--fromString :: String -> Text-fromString = T.pack--toString :: Text -> String-toString = T.unpack--#endif---- | A proxy type for specifying what type a command should return. The final--- field for each data constructor in a command datatype should be @Returns@.-data Returns a = Returns- deriving (Eq, Show, Read, Data, Typeable)---- | Call a command.-call :: (Returns a -> command)- -> (a -> Fay ()) -- ^ Success Handler- -> Fay ()-call f g = ajaxCommand (f Returns) g---- ! Call a command, handling errors as well-callWithErrorHandling- :: (Returns a -> command)- -> (a -> Fay ()) -- ^ Success Handler- -> (Fay ()) -- ^ Failure Handler- -> Fay ()-callWithErrorHandling f g h = ajaxCommandWithErrorHandling (f Returns) g h---- | Run the AJAX command.-ajaxCommand :: Automatic command- -> (Automatic a -> Fay ()) -- ^ Success Handler- -> Fay ()-ajaxCommand = ffi "jQuery['ajax']({ url: window['yesodFayCommandPath'], type: 'POST', data: { json: JSON.stringify(%1) }, dataType: 'json', success : %2})"---- | Run the AJAX command, handling errors as well-ajaxCommandWithErrorHandling- :: Automatic command- -> (Automatic a -> Fay ()) -- ^ Success Handler- -> (Fay ()) -- ^ Failure Handler- -> Fay ()-ajaxCommandWithErrorHandling = ffi "jQuery['ajax']({ url: window['yesodFayCommandPath'], type: 'POST', data: { json: JSON.stringify(%1) }, dataType: 'json', success : %2, error: %3})"-
Yesod/Fay.hs view
@@ -20,11 +20,11 @@ -- containing client-side code, and @fay-shared@ containing code to be used by -- both the client and server. ----- The @Language.Fay.Yesod@ module (part of this package) is+-- The @Fay.Yesod@ module (part of this package) is -- required by both client and server code. However, since Fay does not -- currently have package management support, we use a bit of a hack: the TH -- calls in this package will automatically create the necessary--- @fay\/Language\/Fay\/Yesod.hs@ file. Ultimately, we will use a more elegant+-- @fay\/Fay\/Yesod.hs@ file. Ultimately, we will use a more elegant -- solution. -- -- In the future, if this package proves popular enough, Fay support will@@ -129,7 +129,7 @@ configPrettyPrint, CompileError) #endif-import Language.Fay.Yesod (Returns (Returns))+import Fay.Yesod (Returns (Returns)) import Language.Haskell.TH.Syntax (Exp (LitE, AppE, VarE), Lit (StringL, StringPrimL, IntegerL), Name, Q, qAddDependentFile, qRunIO)@@ -176,7 +176,7 @@ -- -- Most users won't need to define this, the default is @const showToFay@. -- Custom definitions will usually be in terms of 'encodeFay'.- fayEncode :: (Show a, Data a) => master -> a -> Maybe Value+ fayEncode :: (Data a) => master -> a -> Maybe Value fayEncode = const showToFay -- | A function provided by the developer describing how to answer individual@@ -192,7 +192,7 @@ -- and produces the expected result. type CommandHandler master = forall s.- (forall a. (Show a, Data a) => Returns a -> a -> HandlerT master IO s)+ (forall a. (Data a) => Returns a -> a -> HandlerT master IO s) -> Value -> HandlerT master IO s @@ -257,11 +257,11 @@ returnJson $ fayEncode master value -- FIXME what should we do for Nothing values? langYesodFay :: String-langYesodFay = $(qRunIO $ fmap (LitE . StringL . unpack) $ readTextFile "Language/Fay/Yesod.hs")+langYesodFay = $(qRunIO $ fmap (LitE . StringL . unpack) $ readTextFile "Fay/Yesod.hs") writeYesodFay :: IO () writeYesodFay = do- let fp = "fay/Language/Fay/Yesod.hs"+ let fp = "fay/Fay/Yesod.hs" content = "-- NOTE: This file is auto-generated.\n" ++ langYesodFay exists <- isFile fp mcurrent <-@@ -318,7 +318,8 @@ Left e -> return (Left e) Right (sourceAndFiles -> (source',files)) -> do let fps = filter ours files- source = "\n(function(){\n" ++ source' ++ "\n})();\n"+ source | configExportRuntime conf = "\n(function(){\n" ++ source' ++ "\n})();\n"+ | otherwise = source' (fp_hi,fp_o) = refreshTo writeFile fp_hi (unlines fps) writeFile fp_o source
yesod-fay.cabal view
@@ -1,5 +1,5 @@ name: yesod-fay-version: 0.6.1+version: 0.7.0 synopsis: Utilities for using the Fay Haskell-to-JS compiler with Yesod. description: For initial discussion, see <http://www.yesodweb.com/blog/2012/10/yesod-fay-js>. This is a work-in-progress. homepage: https://github.com/fpco/yesod-fay@@ -13,11 +13,11 @@ library exposed-modules: Yesod.Fay- Language.Fay.Yesod+ Fay.Yesod other-modules: Yesod.Fay.Data build-depends: base >= 4 && < 5- , fay >= 0.16- , fay-text+ , fay >= 0.21.2.1+ , fay-dom >= 0.5 , transformers >= 0.2 , aeson >= 0.6 , bytestring >= 0.9