<div dir="ltr">Hello Richard,<div><br></div><div>I think that `:type` should report the real type of an expressions (i.e., the fully generalized inferred type, just like it does now). Certainly I wouldn't want `:type` to show me some kind of (more or less) arbitrary specialization of the type.</div><div><br></div><div>It could be useful to have a ghci command that would show all instantiations of a class method (just 1 level deep) using the instances that are currently in scope. This would be essentially a combination of `:info` on a class and a method. For example, this is what it would look like on some of the methods in 7.10's Prelude:</div><div><br></div><div>:inst length</div><div>length :: [a] -> Int</div><div>length :: Maybe a -> Int</div><div>length :: Either a b -> Int</div><div>length :: (a,b) -> Int</div><div><br></div><div>:inst (==)</div><div>(==) :: Integer -> Integer -> Bool</div><div>(==) :: Word -> Word -> Bool</div><div>...</div><div>(==) :: Eq a => [a] -> [a] -> Bool -- Note that we only instantiate the outer class</div><div>...</div><div>(==) :: (Eq a, Eq b, Eq c) => (a,b,c) -> (a,b,c) -> Bool -- ditto</div><div><br></div><div>:inst mapM</div><div>mapM :: Monad m => (a -> m b) -> [a] -> m [b]</div><div>mapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)</div><div>mapM :: Monad m => (a -> m b) -> Either e a -> m (Either e b)</div><div>mapM :: Monad m => (a -> m b) -> (e,a) -> m (e,b)</div><div><br></div><div>This could be generalized to expressions, rather than just methods, but for expressions with multiple constraints one could get an explosion of possible instantiations. However, it would be quite cool to allow things like this:</div><div><br></div><div>:inst 1</div><div>1 :: Word</div><div>1 :: Integer</div><div>1 :: Int</div><div>1 :: Float</div><div>1 :: Double</div><div><br></div><div>Anyway, just some ideas.</div><div><br></div><div>-Iavor</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 27, 2016 at 8:16 AM, Manuel Gómez <span dir="ltr"><<a href="mailto:targen@gmail.com" target="_blank">targen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Apr 27, 2016 at 10:15 AM, John Leo <<a href="mailto:leo@halfaya.org">leo@halfaya.org</a>> wrote:<br>
> Speaking as someone teaching his coworkers Haskell now, Eric's is the best<br>
> suggestion I've seen so far.<br>
><br>
> What I like about it:<br>
> * The original meaning of :type is unchanged.<br>
> * No new command is added (I prefer adding a flag to adding another<br>
> command).<br>
> * With the flag on, the full type is shown along with the possible<br>
> specializations (and good to note the list might not be exhaustive). This<br>
> way, beginners can still see what the type should look like even if they<br>
> want to ignore it for now. This is similar to learning to read Japanese by<br>
> using furigana. It may be a bit confusing for beginners at first, but I<br>
> expect they'll quickly learn to ignore it until they need it, and I agree it<br>
> will be useful for experienced Haskellers.<br>
<br>
</span>Perhaps a pleasant solution would be to borrow a convention from the<br>
PostgreSQL community's interactive console psql and its meta-commands:<br>
<a href="http://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-META-COMMANDS" rel="noreferrer" target="_blank">http://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-META-COMMANDS</a><br>
<br>
For example:<br>
<br>
> \d[S+] [ pattern ]<br>
><br>
> For each [object] matching the pattern, show all columns, their types, the tablespace (if not the default) and any special attributes such as NOT NULL or defaults. […] The command form \d+ is identical, except that more information is displayed: any comments associated with the columns of the table are shown, as is the presence of OIDs in the table, the view definition if the relation is a view, a non-default replica identitysetting.<br>
<br>
Many psql commands use this convention: add a + to the end of the<br>
command, and you get extra information. It’s quite nmemonic.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</div></div></blockquote></div><br></div>