REPL:如何查找有关类型的信息?
REPL: How can I look up information about a type?
来自 Haskell,我努力寻找一种简单的方法来查找 Purescript 的 REPL 中的类型定义。在 Haskell 中,我可以在 GHCI 中执行以下操作:
-- type class
:info Monad
-- shortcut
:i Monad
-- concrete types
:i []
:i (->)
-- type constructors work as well with a minimized output
:i Just
type Monad :: (* -> *) -> Constraint
class Applicative m => Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
{-# MINIMAL (>>=) #-}
-- Defined in ‘GHC.Base’
instance Monad (Either e) -- Defined in ‘Data.Either’
instance Monad [] -- Defined in ‘GHC.Base’
instance Monad Maybe -- Defined in ‘GHC.Base’
instance Monad IO -- Defined in ‘GHC.Base’
instance Monad ((->) r) -- Defined in ‘GHC.Base’
instance (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)
-- Defined in ‘GHC.Base’
instance (Monoid a, Monoid b) => Monad ((,,) a b)
-- Defined in ‘GHC.Base’
instance Monoid a => Monad ((,) a) -- Defined in ‘GHC.Base’
我在 spago 中找不到类似的东西。有没有办法在不在线搜索的情况下获取此信息,例如 Pursuit?
要获取类型签名,请使用 :type
> :type (1 + _)
> Int -> Int
要显示类型的种类,请使用:kind
> :kind Maybe
> Type -> Type
要查看模块导出的所有函数、类型和类型类,您可以使用浏览器
> :browse Data.Maybe
data Maybe a
= Nothing
| Just a
fromJust :: forall (a :: Type). Partial => Maybe a -> a
......
......
更多信息可以参考this
来自 Haskell,我努力寻找一种简单的方法来查找 Purescript 的 REPL 中的类型定义。在 Haskell 中,我可以在 GHCI 中执行以下操作:
-- type class
:info Monad
-- shortcut
:i Monad
-- concrete types
:i []
:i (->)
-- type constructors work as well with a minimized output
:i Just
type Monad :: (* -> *) -> Constraint
class Applicative m => Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
{-# MINIMAL (>>=) #-}
-- Defined in ‘GHC.Base’
instance Monad (Either e) -- Defined in ‘Data.Either’
instance Monad [] -- Defined in ‘GHC.Base’
instance Monad Maybe -- Defined in ‘GHC.Base’
instance Monad IO -- Defined in ‘GHC.Base’
instance Monad ((->) r) -- Defined in ‘GHC.Base’
instance (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)
-- Defined in ‘GHC.Base’
instance (Monoid a, Monoid b) => Monad ((,,) a b)
-- Defined in ‘GHC.Base’
instance Monoid a => Monad ((,) a) -- Defined in ‘GHC.Base’
我在 spago 中找不到类似的东西。有没有办法在不在线搜索的情况下获取此信息,例如 Pursuit?
要获取类型签名,请使用 :type
> :type (1 + _)
> Int -> Int
要显示类型的种类,请使用:kind
> :kind Maybe
> Type -> Type
要查看模块导出的所有函数、类型和类型类,您可以使用浏览器
> :browse Data.Maybe
data Maybe a
= Nothing
| Just a
fromJust :: forall (a :: Type). Partial => Maybe a -> a
......
......
更多信息可以参考this