Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
mkYesodGeneral: Argument types can now be polymorphic #1055
PR related with #1051.
I made some changes to
The type of
I know this might seem confusing, but I thought it was the closest way to achieve what I wanted without making substantial changes. Plus, everything that worked before, should still work without changes.
An example to explain how the new mkYesodGeneral works:
data Foo a = Foo a class Bar a where ... mkYesodWith "Foo" [Right ["Bar"]] (...)
This would create Yesod types and instances for the type
instance Bar a => YesodDispatch (Foo a) where ...
getSomethingR :: Handler a x getSomethingR = ...
If you write a route handler like:
getSomethingElseR :: Bar a => Handler a x getSomethingElseR = ...
Note that the type variable of polymorphic parameters is not given by the user, but automatically generated by
Please, let me know any changes that are needed to get this functionality merged. I need it for a server I'm writing where the site type is parametrized. This shouldn't affect any yesod users as
Direct link to build issue on ghc 7.8: https://travis-ci.org/yesodweb/yesod/jobs/75128065#L1367
@creichert My current use-case involves a shared state (implemented as a mutable reference in the site type) with a Map, where the keys (maybe elements too) of the map are different in different instances of the server. The types are decided from a configuration file at run time.
The build failure seems to be related with the GHC version used by travis. I'll see how to make it compatible with versions of GHC previous to 7.10.