Skip to content

How to load external libraries #159

@locallycompact

Description

@locallycompact

Hi. I couldn't find this mentioned anywhere.

{-# LANGUAGE LambdaCase, ScopedTypeVariables, TypeApplications #-}
import Data.Typeable
import qualified Language.Haskell.Interpreter.Unsafe as Hint
import qualified Language.Haskell.Interpreter as Hint
import Polysemy

eval :: forall t. Typeable t
     => String -> IO (Either Hint.InterpreterError t)
eval s = Hint.unsafeRunInterpreterWithArgs ["-hide-all-packages", "-package-id", "base-4.17.1.0", "-package-id", "polysemy-1.9.1.0", "-v"] $ do
  Hint.setImports ["Prelude", "Polysemy"]
  Hint.interpret s (Hint.as :: t)

main :: IO ()
main = do
  z <- getLine
  x <- eval @(Sem '[Embed IO] ()) z
  case x of
    Left e -> print e
    Right z ->  runM z

But Hint can't pick up the external library

GhcException "cannot satisfy -package-id polysemy-1.9.1.0\n    (use -v for more information)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions