Skip to content

Commit

Permalink
wording, link
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Díaz committed Apr 9, 2021
1 parent 93761d3 commit 8752576
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lesson9-template-haskell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ If we compile and run the lesson with

Everything should work correctly.

## Where things go wrong: splice code from indefinite libraries
## Where things go wrong: splice code from as-yet indefinite libraries

Suppose that in `Intermediate.hs`, instead of using the splice code from `intermediate-th`, we used
the splice code from `core`, which happens to be exactly identical:
Expand All @@ -49,15 +49,16 @@ Alas, we get an obscure error:
If you suspect the latter, please report this as a GHC bug:
https://www.haskell.org/ghc/reportabug

What is happening here? Why the splice code from `core` causes an error?
What is happening here? Why does the splice code from `core` cause an error?

I'm not 100% sure, but I think the reason is that *splice code from as-yet indefinite packages can't work*.
The reason is that *splice code from as-yet indefinite libraries can't work*.

Why? When building an indefinite library like `core`, it gets typechecked, but
not compiled down to object code. We can't do that, because the library still
has "holes" in it! But that means that other indefinite libraries like
`intermediate` can't run the splice code when they themselves get typechecked,
because the splice code doesn't exist yet.
Why? When we build an indefinite library like `core`, it gets typechecked, but
not compiled down to object code. That can't be done, because the library still
has "holes" in it, in the form of unfilled module signatures. But that means
that other indefinite libraries like `intermediate` can't run the splice code
when they themselves get typechecked, because the splice code doesn't exist
yet.

Moving the `Intermediate.TH` module to `intermediate` won't work either,
because intermediate itself is indefinite.
Expand All @@ -70,6 +71,8 @@ We added a `core` dependency to `lesson9` and tried to splice `Core.TH.makeIdFun

## See also

- [This issue from the Cabal repository](https://github.com/haskell/cabal/issues/7353)

- [This Template Haskell tutorial from Mark Karpov](https://markkarpov.com/tutorial/th.html)

- [template-haskell on Hackage](http://hackage.haskell.org/package/template-haskell)
Expand Down

0 comments on commit 8752576

Please sign in to comment.