When comparing Yesod vs Servant, the Slant community recommends Yesod for most people. In the question“What are the best Haskell web frameworks for building RESTful web services?” Yesod is ranked 1st while Servant is ranked 3rd. The most important reason people chose Yesod is:
While not required, Yesod offers templating through a Shakespearean family of languages to produce page code.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Offers templating for type-safe, well-formed content
While not required, Yesod offers templating through a Shakespearean family of languages to produce page code.
Pro Uses type-safe URLs
Ensures that data provided by the URL is type-safe. This means that data in the URL has a definitive type.
Pro Can be used without knowing much Haskell
While Yesod is written in Haskell, developers can achieve basic functionality without much investment in the language.
Pro Automatic documentation and Haskell/JS query generation
Routes are defined end-to-end with type declarations. This allows your API to be introspective, serving its own documentation and derived query code, via jQuery for Javascript and servant-client
for Haskell.
Pro Excellent documentation
We Haskellers are accustomed to flying completely blind when using many libraries, luckily with Servant this isn’t the case. It features comprehensive tutorials, literate haskell examples for many use cases and great Haddock documentation for everything else.
Pro No Template Haskell
Everything is done within the confines of the existing type system, which helps keep compile times down.
Pro Nice ecosystem
Fairly large ecosystem of related modules for additional functionality.
Cons
Con Is hard to customize
Learning how Yesod works internally is hard. It is a large framework with complicated components. Finding the appropriate code and understanding how it contributes to the framework is difficult, meaning developers will struggle.
Con Too much template haskell
You actually want to code in haskell and not some DSL with "magic" hidden under the bonnet.
Con Complicated internals
Extending Servant's existing functionality can be made difficult by the complexity of its type level machinery. Lucky most use cases are able to avoid this.
Con Route specifications and implementations are only connected by their position in a large type list
You actually have to count the index of the entry where you changed the specification, and then go and change the entry at the same index in the list of implementation methods. There is no other indication that the two are connected. This along with complex and verbose route definitions, makes it very hard to safely make changes to an API.
Con Route definitions are more verbose and complicated than other options
You are required to define a number of separate complicated types and their implementations which are usually spread out over a number of files. This makes it hard to figure out the API.