2

Doing week 04, watching "PPP 030403 - The EmulatorTrace Monad"

In the repl, having already imported as follows

>import Data.Char
>import Text.Read
>import Plutus.Trace.Emulator
>import Data.Default

If I enter ":t TraceConfig" I see

Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default> :t TraceConfig
TraceConfig
  :: (Wallet.Emulator.MultiAgent.EmulatorEvent' -> Maybe String)
     -> GHC.IO.Handle.Types.Handle -> TraceConfig
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default>
Attempting to explore that, I enter (and get error) as follows:
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default> :t Wallet.Emulator.MultiAgent.EmulatorEvent'
 
:1:1: error:
    Not in scope:
      data constructor ‘Wallet.Emulator.MultiAgent.EmulatorEvent'’
    No module named ‘Wallet.Emulator.MultiAgent’ is imported.
 
 
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default> :i Wallet.Emulator.MultiAgent.EmulatorEvent'
type Wallet.Emulator.MultiAgent.EmulatorEvent' :: *
data Wallet.Emulator.MultiAgent.EmulatorEvent'
  = Wallet.Emulator.MultiAgent.ChainEvent Wallet.Emulator.Chain.ChainEvent
  | Wallet.Emulator.MultiAgent.ClientEvent Wallet.Emulator.Wallet.Wallet
                                          Wallet.Emulator.NodeClient.NodeClientEvent
  | Wallet.Emulator.MultiAgent.WalletEvent Wallet.Emulator.Wallet.Wallet
                                         Wallet.Emulator.Wallet.WalletEvent
  | Wallet.Emulator.MultiAgent.ChainIndexEvent Wallet.Emulator.Wallet.Wallet
                                          plutus-chain-index-core-0.1.0.0:Plutus.ChainIndex.ChainIndexLog.ChainIndexLog
  | Wallet.Emulator.MultiAgent.SchedulerEvent Plutus.Trace.Scheduler.SchedulerLog
  | Wallet.Emulator.MultiAgent.InstanceEvent Plutus.Trace.Emulator.Types.ContractInstanceLog
  | Wallet.Emulator.MultiAgent.UserThreadEvent Plutus.Trace.Emulator.Types.UserThreadMsg
      -- Defined in ‘Wallet.Emulator.MultiAgent’
instance Eq Wallet.Emulator.MultiAgent.EmulatorEvent'
  -- Defined in ‘Wallet.Emulator.MultiAgent’
instance Show Wallet.Emulator.MultiAgent.EmulatorEvent'
  -- Defined in ‘Wallet.Emulator.MultiAgent’
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default>
My question is, why does ":i" (requesting info about) work, but ":t" (requesting merely the type, which is actually included in the info) does not? Tracking these multiple nestings of data structures is straining my brain.

1 Answer 1

4

Take into account that :t is for getting the type of a function, and EmulatorEvent' is not a function but a type. So, because it's a type you can use :i EmulatorEvent' but not :t EmulatorEvent'.

You can use :t with the constructors (they are functions) of EmulatorEvent', say :t ChainEvent.

enter image description here

5
  • Part of me thinks this should "fail" gracefully, since the focus of the monad video was elegant failure.
    – XiTouch
    Commented Feb 6, 2022 at 1:43
  • What do you mean with fail gracefully? Can you elaborate?
    – kindofdev
    Commented Feb 6, 2022 at 10:40
  • @XiTouch, Do you consider that my answer is correct? I so, you might accept it and help others wiith the same question. Thanks!
    – kindofdev
    Commented Feb 6, 2022 at 19:49
  • 1
    your answer is helpful, correct, useful, the best offered, and the best ever likely to be offered so yes, it's "answered" and thank you. By "fail gracefully" I mean cabal should produce a message that is helpful and accurately informative, rather than basically "you screwed up, I won't help you, you should know better." For example, a message like "foo is not a type. Use {>:i foo} for info about foo".
    – XiTouch
    Commented Feb 6, 2022 at 20:52
  • 1
    @XiTouch, I agree that the message is not very helpful (in general Haskell error messages are not good), but this message doesn't come from cabal or Plutus. :t and :i is a ghci thing.
    – kindofdev
    Commented Feb 6, 2022 at 21:41

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.