lukexi / halive

Live recompiler for Haskell
BSD 2-Clause "Simplified" License
263 stars 18 forks source link

(Optionally) copy '-package-id' args from 'stack' #13

Open afcady opened 8 years ago

afcady commented 8 years ago

If the environment variable 'HALIVE_STACK_COMPONENT' is set, its value will be passed to 'stack ghci' as the component to use. The command line used to launch 'ghci' is extracted from 'stack' log output, and the '-package-id=<...>' arguments used to configure the 'DynFlags' passed to 'runGhc'.

This is necessary when the stack package dbs contain multiple packages that provide the same module. Without it, 'runGhc' will not be able to know which package should be used to provide the module, producing an error such as this:

demo/Shader.hs:3:8: Ambiguous module name ‘Graphics.GL’: it was found in multiple packages: gl-0.7.7@gl_8feL1KNX30C7cRvC5KMerD OpenGLRaw-3.0.0.0@OpenG_2ifknuoKtb4Jnk98tmsl6Y

This is very slow, since it has to compile the project with 'ghci' just to get the arguments -- only to be used to compile it again! But it does make 'halive' work in situations where, without it, there would only be failure.

(A proper solution would involve modifying 'stack' to provide this information more efficiently.)