3

I'm making a Yesod subsite and am getting a type error in some Template Haskell-generated code:

Yesod\DataSource\Data.hs:19:1:
Couldn't match type `[Char]' with `Text'
Expected type: () -> ([Text], [(Text, Text)]) -> Maybe (Route DataSource)
  Actual type: () -> ([[Char]], [(Text, Text)]) -> Maybe (Route DataSource)
In the first argument of `\ f_amMs x_amMt -> f_amMs () x_amMt ::
                            forall a_amMu.
                            (() -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu))
                            -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu)', namely
  `helper_amMr'
In the expression:
    \ f_amMs x_amMt -> f_amMs () x_amMt ::
      forall a_amMu.
      (() -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu))
      -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu)
    helper_amMr

The problem is clear, but I don't understand why it's generating incorrect code.

The issue occurs in this TH call:

mkYesodSubData "DataSource" [parseRoutes|
/ SubHomeR GET
/datasource DataSourceInputR POST GET
|]

Specifically, it is caused by the line:

/datasource DataSourceInputR POST GET

Removing this line fixes the issue.

I'm using Stackage LTS 1.15:

remote-repo: stackage-lts-1.15:http://www.stackage.org/snapshot/lts-1.15

And I'm inside a cabal sandbox.

Here are the relevant files: https://gist.github.com/BeerendLauwers/774cc432c3ada5b597e1

Any idea?

Beerend Lauwers
  • 872
  • 7
  • 14
  • If you're sure that it's a bug in Yesod, try to create a minimal example and post an issue on [github](https://github.com/yesodweb/yesod/issues). – Zeta Apr 01 '15 at 11:06

1 Answers1

6

I think that the generated code expects that you have the OverloadedStrings extension enabled in your source file. Try adding

{-# LANGUAGE OverloadedStrings #-}

to the top of the source file where you splice in the Template Haskell code (i.e. Data.hs).

shang
  • 24,642
  • 3
  • 58
  • 86