Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document GHC-12219: static forms cannot be used in splices #494

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions message-index/messages/GHC-12219/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: static forms cannot be used in splices
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even while GHC itself starts the error message from lower case, I'd prefer to keep titles in title case.

Suggested change
title: static forms cannot be used in splices
title: Static forms cannot be used in splices

summary: Static forms are disallowed in splices
severity: error
introduced: 9.6.1
---

```
static.hs:7:45: error: [GHC-12219]
• static forms cannot be used in splices: static 'a'
• In the untyped splice: $(lift (show $ staticKey $ static 'a'))
```

GHC does not support using a static form in a splice, i.e. obtaining a reference
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that it's tedious, but IMHO it's worth to provide readers with more context, especially when it comes to rare features of the language. Those who are already in the know what is a static form and what is a splice are not our target audience. For someone who encountered the error just by making a typo it would help to know which language extensions are involved and have a link to the GHC manual at ready.

I'd suggest to spell out "TemplateHaskell splices" in full, to make it unambiguous.

to a `StaticPtr` at compile time
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE TemplateHaskell #-}
module StaticSplice where

import GHC.StaticPtr
import Language.Haskell.TH.Syntax

main = print $([| show $ staticKey $ static 'a' |])


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE TemplateHaskell #-}

module StaticSplice where

import GHC.StaticPtr
import Language.Haskell.TH.Syntax

main = print =<< $(lift (show $ staticKey $ static 'a') )
9 changes: 9 additions & 0 deletions message-index/messages/GHC-12219/staticsplice/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: GHC does not support defining static pointers in splices
---

You can't use a static forms in a splice - i.e. you can't obtain a `StaticPtr`
in code that runs at compile time.

Evaluating a quote that has a static form is not a problem, since this is code
that will be evaluated at run time.
Loading