<div dir="ltr">Speaking as someone teaching his coworkers Haskell now, Eric's is the best suggestion I've seen so far.<div><br></div><div>What I like about it:</div><div>* The original meaning of :type is unchanged.</div><div>* No new command is added (I prefer adding a flag to adding another command).</div><div>* With the flag on, the full type is shown along with the possible specializations (and good to note the list might not be exhaustive). This way, beginners can still see what the type should look like even if they want to ignore it for now. This is similar to learning to read Japanese by using furigana. It may be a bit confusing for beginners at first, but I expect they'll quickly learn to ignore it until they need it, and I agree it will be useful for experienced Haskellers.</div><div><br></div><div>John</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 26, 2016 at 5:18 PM, Eric Seidel <span dir="ltr"><<a href="mailto:eric@seidel.io" target="_blank">eric@seidel.io</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think design A (deeply instantiate + generalize) produces the most<br>
sensible types. I don't know what the curly braces mean (perhaps that we<br>
can't use type application anymore since the order changed?) but I don't<br>
think they'd show up at all without -fprint-explicit-foralls, right? If<br>
so, I'm not too concerned about it.<br>
<br>
I also think 2C is a neat idea and should be explored further, but I<br>
don't think it should be the default behavior of :type. I've always<br>
expected :type to print the exact type we would infer for the<br>
expression.<br>
<br>
Perhaps instead of changing the default behavior of :type or adding new<br>
commands, we could add a flag to enhance :type's output. For example,<br>
<br>
> :type mapM<br>
mapM :: (Monad m, Traversable t) => (a -> m b) -> t a -> m (t b)<br>
> :set -fprint-type-specializations<br>
> :type mapM<br>
mapM :: (Monad m, Traversable t) => (a -> m b) -> t a -> m (t b)<br>
Possible Specializations:<br>
mapM :: Monad m => (a -> m b) -> [a] -> m [b]<br>
mapM :: (a -> Maybe b) -> [a] -> Maybe [b]<br>
...<br>
<br>
I think this could be useful even for experienced Haskellers, though I'm<br>
a bit concerned that printing the full type at the top will leave<br>
beginners as bewildered as ever..<br>
<span class="HOEnZb"><font color="#888888"><br>
Eric<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Tue, Apr 26, 2016, at 06:08, Richard Eisenberg wrote:<br>
> Hi devs,<br>
><br>
> Over the weekend, I was pondering the Haskell course I will be teaching<br>
> next year and shuddered at having to teach Foldable at the same time as<br>
> `length`. So I implemented feature request #10963<br>
> (<a href="https://ghc.haskell.org/trac/ghc/ticket/10963" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/10963</a>), which allows for a way<br>
> for a user to request a specialization of a type. It all works<br>
> wonderfully, but there is a real user-facing design issue here around the<br>
> default behavior of :type and whether or not to add new :type-y like<br>
> commands. I have outlined the situation here:<br>
> <a href="https://ghc.haskell.org/trac/ghc/wiki/Design/GHCi/Type" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Design/GHCi/Type</a><br>
><br>
> I'd love some broad input on this issue. If you've got a stake in how<br>
> this all works, please skim that wiki page and comment on #10963.<br>
><br>
> Thanks!<br>
> Richard<br>
> _______________________________________________<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>
_______________________________________________<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>