Reputation:
I have an error in this code in Snap haskell app:
import Snap.Http.Server
import Snap.Core
import Snap.Snaplet
import Snap.Snaplet.Heist
import Snap.Util.FileServe
import Snap.Util.GZip
import Heist.Interpreted
import Heist
data App = App { appHeist :: Snaplet (Heist App) }
routes :: [(ByteString, Handler App App ())]
routes = [("", serveDirectory "static")]
appInit :: SnapletInit App App
appInit = makeSnaplet "app" "An snaplet example application." Nothing $ do
h <- nestSnaplet "" heist $ heistInit "templates"
addRoutes routes
return $ App h
The error is:
Not in scope: ‘heist’
and I can't find in what package the function "heist" is.
Note that I'm not using Lens and don't want to. Is there any way not to use them and make my code compile?
Upvotes: 0
Views: 68
Reputation: 3739
I'm not familiar with Snap, but judging from the type signature of nestSnaplet
, it looks like you're going to need to use a lens of some sort. nestSnaplet
has the signature
nestSnaplet :: ByteString -> SnapletLens v v1 -> SnapletInit b v1-> Initializer b v (Snaplet v1)
where SnapletLens
is just a type synonym for an Alens
from lens
.
That also leads me to suspect that heist
was originally a Template Haskell derived function made using lens
. Probably what happened is that App
used to look like this:
-- You may need to import Contol.Lens.TH
data App = App { _heist :: Snaplet (Heist App) }
makeLenses ''App
which would have made heist
a lens.
Upvotes: 1