使 REPL 输出记录类型的名称?
Make the REPL output the name of a record type?
来自section 3.11 of Purescript By Example:
然而,当我在我的 REPL 中尝试同样的操作时,我得到:
也就是说,它输出文字表示,而不是类型的名称,Entry
。我是否需要以某种方式配置 REPL 才能像书中那样运行?
如果要按名称显示类型,则需要类型构造函数而不是类型别名。
pulp repl
> import Data.Record.ShowRecord -- from "purescript-record-show"
> data Address = Address {street :: String, city :: String, state :: String}
> address = Address {street: "main", city: "SanFran", state: "CA"}
> instance showAddress :: Show Address where show (Address rec) = "Address " <> showRecord rec
> address
Address { city: "SanFran", state: "CA", street: "main" }
> :t address
Address
来自section 3.11 of Purescript By Example:
然而,当我在我的 REPL 中尝试同样的操作时,我得到:
也就是说,它输出文字表示,而不是类型的名称,Entry
。我是否需要以某种方式配置 REPL 才能像书中那样运行?
如果要按名称显示类型,则需要类型构造函数而不是类型别名。
pulp repl
> import Data.Record.ShowRecord -- from "purescript-record-show"
> data Address = Address {street :: String, city :: String, state :: String}
> address = Address {street: "main", city: "SanFran", state: "CA"}
> instance showAddress :: Show Address where show (Address rec) = "Address " <> showRecord rec
> address
Address { city: "SanFran", state: "CA", street: "main" }
> :t address
Address