hakyll icon indicating copy to clipboard operation
hakyll copied to clipboard

Expose SomeItem?

Open ip1981 opened this issue 7 years ago • 2 comments

I guess I need data SomeItem to be exposed/exported, otherwise I seem can't use rulesCompilers from RuleSet:

rulesCompilers :: [(Identifier, Compiler SomeItem)]

SomeItem is not exposed, so I can't for example define types of functions, and GHC fails to match any of my code with Hakyll.Core.Item.SomeItem.SomeItem.

P. S. I think the actual problem is to recover original compiler (Compiler (Item a)) from Compiler SomeItem.

ip1981 avatar Oct 27 '18 17:10 ip1981

I'm happy with exposing this but maybe there's another way to get out what you want? What are you trying to do?

jaspervdj avatar May 31 '19 08:05 jaspervdj

I am trying to "postprocess" the rules. That's I write the rules for a site in the normal way, than I want to extend the site by creating a translated site (with po4a). Something like this:

newRules ::
     [String]
  -> Routes
  -> Provider
  -> (Identifier, Compiler SomeItem)
  -> IO (Rules ())
newRules langs routes provider (identifier, somecomp) = do
  mrt <- fst <$> Routes.runRoutes routes provider identifier
  return $
    case mrt of
      Nothing -> create [identifier] (compileSome somecomp)
      Just rt ->
        if needTranslation rt
          then mapM_ mkPages langs
          else create [identifier] $ do
                 route (constRoute rt)
                 compileSome somecomp
        where mkPages lang = do
                let rtt = mkLangRoute lang rt
                    rto = mkLangRoute origLang rt
                    orig = destinationDirectory config </> rto
                if rtt == rto
                  then create [identifier] $ do
                         route (constRoute rtt)
                         compileSome somecomp
                  else create [identifier] $
                       rulesExtraDependencies
                         [ IdentifierDependency . fromFilePath . poFile $ lang
                         , IdentifierDependency . fromFilePath $ orig
                         ] $
                       version lang $ do
                         route (constRoute rtt)
                         compile (translate orig lang)

ip1981 avatar May 31 '19 09:05 ip1981