daml/bazel_tools/haskell-js-flot.patch
Moritz Kiefer 668373ca85
Embed shake data-files via TH (#4584)
This is a bit ugly but after spending some time digging into the
issues in rules_haskell around data-files, this seems like the most
sensible option especially given that we also want to ship them in the
SDK which woud require additional work even if we do fix it in
rules_haskell.

fixes #4457

changelog_begin
changelog_end
2020-02-18 17:53:27 +01:00

50 lines
1.5 KiB
Diff

diff --git a/Language/Javascript/Flot.hs b/Language/Javascript/Flot.hs
index aefee8b..cd73443 100644
--- a/Language/Javascript/Flot.hs
+++ b/Language/Javascript/Flot.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE TemplateHaskell #-}
-- | Module for accessing minified flot code (<http://www.flotcharts.org/>).
-- As an example:
@@ -9,13 +10,14 @@
-- > putStrLn $ "Flot version " ++ show Flot.version ++ " source:"
-- > putStrLn =<< readFile =<< Flot.file Flot.Flot
module Language.Javascript.Flot(
- Flot(..), version, file
+ Flot(..), version, file, flotFileContent, flotStackFileContent
) where
import qualified Paths_js_flot as Paths
import Data.Version
import Data.Data
import Data.Char
+import Data.FileEmbed
-- | The Flot code to obtain. Use 'Flot' for the base system and the other values
@@ -42,6 +44,8 @@ data Flot
file :: Flot -> IO FilePath
file = Paths.getDataFileName . name
+flotFileContent = $(embedFile "javascript/jquery.flot.min.js")
+flotStackFileContent = $(embedFile "javascript/jquery.flot.stack.min.js")
name Flot = "jquery.flot.min.js"
name x = "jquery.flot." ++ map toLower (drop 4 $ show x) ++ ".min.js"
diff --git a/js-flot.cabal b/js-flot.cabal
index 2dabdb0..4b927df 100644
--- a/js-flot.cabal
+++ b/js-flot.cabal
@@ -48,7 +48,8 @@ source-repository head
library
default-language: Haskell2010
build-depends:
- base == 4.*
+ base == 4.*,
+ file-embed
exposed-modules:
Language.Javascript.Flot