I'm trying to understand at the lowest level exactly how Plutus/Haskell/Cabal works.

I executed the following in the repl (inside nix):

> import PlutusTx.Builtins.Internal as PTxBI

Doing this causes no error, and I see the Prelude prompt now includes "PTxBI".

Yet I cannot work with "PTxBI". I cannot browse it, get info, etc. The image shows some of my attempts (mostly to see what error messages get generated). I find the "not in scope" errors very curious.

If I enter

> :browse PlutusTx.Builtins.Internal

I do get meaningful, error-free output.

Why does the repl not recognize "PTxBI"? It obviously recognized it well enough to include it in the Prelude prompt. This feels like broken behavior.

enter image description here

1 Answer 1

  1. browse: apparently you can't use the alias of an imported module when browsing
import Data.Maybe as DM
:browse Data.Maybe           ~> works
:browse DM                   ~> throws an error
  1. info: according to the docs, :i gives you information about a name. The alias of a module is not a name, neither is the name of the module, i.e.
:i Data.Maybe   ~> throws an error  
:i Maybe        ~> works
  1. type: according to the docs, :t gives you the type of an expression. The alias/name of a module is not an expression, i.e.
:t Data.Maybe   ~> throws an error  
:t Maybe        ~> throws an error, a type is not an expression  
:t Just         ~> works
  1. let m = PTxBI 17: you need a constructor after the equal sign, not the alias of a module. You could write PTxBI.BuiltinInteger.
  • Point #1 was the main thing, and you've basically confirmed my experience (2-4 were just doodles to see what error was produced). I suppose rather than "broken" behavior this is more properly viewed as "incomplete" behavior, but IMHO if you're going to specify an alias for something, that alias should work everywhere that the something works.
    – XiTouch
    Commented Mar 3, 2022 at 4:16
  • 1
    I couldn't tell you where ghci is maintained, but perhaps you could report this as an issue. Commented Mar 3, 2022 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.