haskell / haskell/haskell-language-server

Evaluating `TemplateHaskell`

Open
#2,946 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

# Example project
So I created a minimal project showcasing the problem [here](https://github.com/ndzik/minex).

# Versions
`hie-bios version 0.8.1 compiled by GHC 8.10.7`
Project also compiles with `GHC 8.10.7`
In case of relevance also the version for HLS:
`haskell-language-server version: 1.7.0.0 (GHC: 8.10.7)`

# Problem
I am playing around a bit with [plutus](https://github.com/input-output-hk/plutus-apps/tree/v2022-04-06s) and write some smart contracts.
I was able to get HLS to work with my project up to a point were I am only left with a seemingly false negative related to the evaluation of TemplateHaskell code as far as I can tell.

I do not know if this might be a general problem with template haskell evaluation and quasiquotation or if it is just me missing some dependency for `hie-bios` to work.

Some more information can be found in my example project.

Surprisingly HLS still is able to type everything correctly, it just keeps complaining where the plutus code is generated:

```
hie-bios: GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable Ledger.Typed.Scripts.Validators.wrapValidator
No unfolding
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
@ MyLib.ExampleInput
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
@ MyLib.ExampleInput @ MyLib.ExampleInput
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
@ MyLib.ExampleInput
@ MyLib.ExampleInput
MyLib.$fUnsafeFromDataExampleInput
Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
@ MyLib.ExampleInput
@ MyLib.ExampleInput
MyLib.$fUnsafeFromDataExampleInput
MyLib.$fUnsafeFromDataExampleInput
Context: Compiling expr at "minex-0.1.0.0-inplace:MyLib:(36,8)-(36,35)"
```

Maybe someone here can point me in the right direction (:

Thanks for your time, kind reader.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.