Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:56:12+00:00 2026-06-12T02:56:12+00:00

I could not figure out why I am getting GHC stage restriction in the

  • 0

I could not figure out why I am getting “GHC stage restriction” in the following code:

import Language.Haskell.TH

rules :: [ExpQ]
rules = [ [| \a -> a |], [| \_ -> 1 |] ]

findTransforms :: Int -> [ExpQ] -> Bool
findTransforms _ [] = False
findTransforms e (r:rs) = if ($r e) == 1 then True else findTransforms e rs

(Do not worry if code does not make anything useful – it is extracted minimal example obfuscated for clarity).

I do not call any functions from spliced code. Why stage restriction?

EDIT1: edited to give even simpler code example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:56:14+00:00Added an answer on June 12, 2026 at 2:56 am

    This fails for the same reason you can’t write

     eval :: ExpQ -> Int
     eval expr = $expr
    

    because it would require compilation at run-time.

    One solution is to make findTransforms compile-time as well by returning an expression of nested if expressions rather than the value of said expression.

    findTransforms :: Int -> [ExpQ] -> ExpQ
    findTransforms _ []     = [| False |]
    findTransforms e (r:rs) = [| if $r e == 1 then True else $(findTransforms e rs) |]
    

    Of course, this means that you’ll have to splice it when you want to use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could not figure out how to get the white fill for this ggplot2
i just could not figure out how i will put my data on a
I'm trying to play with inter-process communication and since I could not figure out
I am looking at the query syntax . and i could not figure out
A really simple question but I could not figure it out... I tried to
it looks very basic thing but i could not figure it out. var email
I'm not seeing the error and was hoping someone could figure it out: public
I have been trying this for some time but could not figure out yet.
I could not figure out why this is happening. I'm using PHP server and
well i have most probably an extremly stupid problem but could not figure it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.