Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Illegal view pattern: fromPathPiece -> Just dyn_abDD" when using parameters on routes

Tags:

haskell

yesod

I'm using yesod version 1.4.0 within a cabal sandbox.

I have the following routes file:

/static StaticR Static getStatic
/auth   AuthR   Auth   getAuth

/favicon.ico FaviconR GET
/robots.txt RobotsR GET

/ HomeR GET POST
/config/#String MakeConfigR GET POST

and a matching (properly imported and everything) handler file for the implementation.

However, whenever yesod (or when I manually) try to compile, I get the following error

Foundation.hs:48:1:
    Illegal view pattern:  fromPathPiece -> Just dyn_abDD
    Use -XViewPatterns to enable view patterns

I haven't modified Foundation.hs in any way.

When I only have a route that takes no parameters, such as

/noparamshere NoParamsR GET

or something similar in my routes file, everything works fine. What have I done wrong?

like image 658
Unknownloner Avatar asked Oct 06 '14 22:10

Unknownloner


1 Answers

I guess you have created your project with an old version of yesod. As of yesod-1.4.0, you need to enable ViewPatterns extension as the error message indicates. Add ViewPatterns to default-extensions in your cabal file.

like image 160
snak Avatar answered Nov 06 '22 11:11

snak