Commit ebd9026b authored by Kai-Oliver Prott's avatar Kai-Oliver Prott

FIx fail when embedding data file for the first time

parent 353467ff
......@@ -52,6 +52,7 @@ Library
, mtl
, pretty
, process
, file-embed
, set-extra
, transformers
if flag(network-uri)
......@@ -106,7 +107,6 @@ Library
, Env.Value
, Exports
, Files.CymakePath
, Files.Embed
, Generators
, Generators.GenAbstractCurry
, Generators.GenFlatCurry
......@@ -133,9 +133,11 @@ Library
, Transformations.Newtypes
, Transformations.Qual
, Transformations.Simplify
Other-Modules:
other-modules:
Paths_curry_frontend
ghc-options: -Wall -fno-warn-orphans
autogen-modules:
Paths_curry_frontend
ghc-options: -Wall
Executable curry-frontend
hs-source-dirs: src
......@@ -154,13 +156,14 @@ Executable curry-frontend
, mtl
, pretty
, process
, file-embed
, set-extra
, transformers
if flag(network-uri)
build-depends: network-uri >= 2.6
else
build-depends: network < 2.6
ghc-options: -Wall -fno-warn-orphans
ghc-options: -Wall
Test-Suite test-frontend
type: detailed-0.9
......
......@@ -10,7 +10,7 @@
TODO
-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Base.PrettyKinds where
import Curry.Base.Pretty
......
......@@ -10,7 +10,8 @@
TODO
-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Base.PrettyTypes where
#if __GLASGOW_HASKELL__ >= 804
......
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module Files.Embed (embedDataFile, cssFileName) where
import Prelude (FilePath, Monad(..), ($), fromIntegral)
import Data.ByteString.Unsafe (unsafePackAddressLen)
import Data.ByteString (ByteString, unpack, length, readFile)
import System.IO.Unsafe (unsafePerformIO)
import Language.Haskell.TH.Syntax (Q, Exp(..), Lit(..), runIO)
import Paths_curry_frontend (getDataFileName)
-- | embed a file from the data dir within the code
embedDataFile :: FilePath -> Q Exp
embedDataFile fn = do
fp <- runIO $ getDataFileName fn
c <- runIO $ readFile fp
bsToExp c
bsToExp :: ByteString -> Q Exp
bsToExp bs =
return $ VarE 'unsafePerformIO
`AppE` (VarE 'unsafePackAddressLen
`AppE` LitE (IntegerL $ fromIntegral $ length bs)
`AppE` LitE (StringPrimL $ unpack bs))
cssFileName :: FilePath
cssFileName = "currysource.css"
......@@ -20,6 +20,7 @@ import Control.Monad.Writer
import Data.List (mapAccumL)
import Data.Maybe (fromMaybe, isJust)
import Data.ByteString as BS (ByteString, writeFile)
import Data.FileEmbed
import Network.URI (escapeURIString, isUnreserved)
import System.FilePath ((</>))
......@@ -32,13 +33,17 @@ import Curry.Syntax (Module (..), Token)
import Html.SyntaxColoring
import Files.Embed
import CompilerOpts (Options (..))
-- |Read file via TemplateHaskell at compile time
cssContent :: ByteString
cssContent = $(embedDataFile cssFileName)
cssContent = $(makeRelativeToProject "data/currysource.css" >>= embedFile)
-- | Name of the css file
-- NOTE: The relative path is given above
cssFileName :: String
cssFileName = "currysource.css"
-- |Translate source file into HTML file with syntaxcoloring
source2html :: Options -> ModuleIdent -> [(Position, Token)] -> Module a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment