Purescript: Add a `:find` command to psci, to locate things in the currently loaded module environment

Created on 23 Mar 2017  路  4Comments  路  Source: purescript/purescript

Or better still, make it fancy so it can do type-lookups etc. too :smile:

enhancement purs repl

Most helpful comment

For reference, one way to do type-lookups at the moment is with an annotated hole:

> ?find :: Array _ -> Int
Error found:
in module $PSCI
at  line 1, column 1 - line 1, column 6

  Hole 'find' has the inferred type

    Array t0 -> Int

  You could substitute the hole with one of these values:

    $PSCI.it                    :: Array t0 -> Int
    Data.Array.length           :: forall a. Array a -> Int
    Data.Foldable.product       :: forall a f.
                                     ( Foldable f
                                     , Semiring a
                                     ) => f a -> a
    Data.Foldable.sum           :: forall a f.
                                     ( Foldable f
                                     , Semiring a
                                     ) => f a -> a
    Data.Semiring.one           :: forall a. (Semiring a) => a
    Data.Semiring.zero          :: forall a. (Semiring a) => a
    Unsafe.Coerce.unsafeCoerce  :: forall a b. a -> b

However I don't think this includes declarations defined in the repl session.

All 4 comments

For reference, one way to do type-lookups at the moment is with an annotated hole:

> ?find :: Array _ -> Int
Error found:
in module $PSCI
at  line 1, column 1 - line 1, column 6

  Hole 'find' has the inferred type

    Array t0 -> Int

  You could substitute the hole with one of these values:

    $PSCI.it                    :: Array t0 -> Int
    Data.Array.length           :: forall a. Array a -> Int
    Data.Foldable.product       :: forall a f.
                                     ( Foldable f
                                     , Semiring a
                                     ) => f a -> a
    Data.Foldable.sum           :: forall a f.
                                     ( Foldable f
                                     , Semiring a
                                     ) => f a -> a
    Data.Semiring.one           :: forall a. (Semiring a) => a
    Data.Semiring.zero          :: forall a. (Semiring a) => a
    Unsafe.Coerce.unsafeCoerce  :: forall a b. a -> b

However I don't think this includes declarations defined in the repl session.

Yeah, I know about that one. 馃憤

This was a suggestion based on a question someone had in Slack about whether it was possible to find where things were defined via the repl, but giving it "Pursuit powers" just seemed like a natural extension.

Should this be promoted to "Approved"? It doesn't sound like there's much more to discuss other than implementation?

I think it could do with a slightly more detailed specification; it's not entirely clear to me how this should work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garrett-hopper picture garrett-hopper  路  3Comments

mpodlasin picture mpodlasin  路  4Comments

vladciobanu picture vladciobanu  路  4Comments

LiamGoodacre picture LiamGoodacre  路  3Comments

joneshf picture joneshf  路  4Comments