Displaying specializations in :info or separately?

Hi, I'm working on a GHC feature [1] that allows users to view specializations of functions like in (name subject to change) ----
:binfo find find :: Foldable t => (a -> Bool) -> t a -> Maybe a Specialisations: t ~ [] => find :: (a -> Bool) -> [a] -> Maybe a
:binfo first first :: Arrow a => a b c -> a (b, d) (c, d) Specialisations: a ~ (->) => first :: (b -> c) -> (b, d) -> (c, d)
Now there are two things left to decide on: * What command should the specializations be visible under? We can either put it under :info or make a special command :sinfo or :binfo that displays only the expression's type and specialisations like in the example above? * What specializations do we want to display? goldfire suggested using the default list, which has the added benefit of being customizable by e.g. instructors, so adding a default Maybe (in conjunction with [2]) gives the desired behavior and not too many specializations. Thanks for your time! David ---- Links: [1] : https://ghc.haskell.org/trac/ghc/ticket/10972 [2] : https://ghc.haskell.org/trac/ghc/ticket/10971

I would avoid the `(t ~ []) =>` prefix -- it might be confusing to the newcomers this feature is meant to serve. How about
With t := []: find :: (a -> Bool) -> [a] -> Maybe a
?
Richard
On Oct 19, 2015, at 12:47 PM, David Kraeutmann
Hi,
I'm working on a GHC feature [1] that allows users to view specializations of functions like in (name subject to change)
----
:binfo find find :: Foldable t => (a -> Bool) -> t a -> Maybe a Specialisations: t ~ [] => find :: (a -> Bool) -> [a] -> Maybe a
:binfo first first :: Arrow a => a b c -> a (b, d) (c, d) Specialisations: a ~ (->) => first :: (b -> c) -> (b, d) -> (c, d)
Now there are two things left to decide on: * What command should the specializations be visible under? We can either put it under :info or make a special command :sinfo or :binfo that displays only the expression's type and specialisations like in the example above?
* What specializations do we want to display? goldfire suggested using the default list, which has the added benefit of being customizable by e.g. instructors, so adding a default Maybe (in conjunction with [2]) gives the desired behavior and not too many specializations.
Thanks for your time! David
---- Links: [1] : https://ghc.haskell.org/trac/ghc/ticket/10972 [2] : https://ghc.haskell.org/trac/ghc/ticket/10971
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Or
When t is []: find :: (a -> Bool) -> [a] -> Maybe a
if this really is for the newcomer!
Doug
On Mon, Oct 19, 2015 at 3:11 PM Richard Eisenberg
I would avoid the `(t ~ []) =>` prefix -- it might be confusing to the newcomers this feature is meant to serve. How about
With t := []: find :: (a -> Bool) -> [a] -> Maybe a
?
Richard
On Oct 19, 2015, at 12:47 PM, David Kraeutmann
wrote: Hi,
I'm working on a GHC feature [1] that allows users to view specializations of functions like in (name subject to change)
----
:binfo find find :: Foldable t => (a -> Bool) -> t a -> Maybe a Specialisations: t ~ [] => find :: (a -> Bool) -> [a] -> Maybe a
:binfo first first :: Arrow a => a b c -> a (b, d) (c, d) Specialisations: a ~ (->) => first :: (b -> c) -> (b, d) -> (c, d)
Now there are two things left to decide on: * What command should the specializations be visible under? We can either put it under :info or make a special command :sinfo or :binfo that displays only the expression's type and specialisations like in the example above?
* What specializations do we want to display? goldfire suggested using the default list, which has the added benefit of being customizable by e.g. instructors, so adding a default Maybe (in conjunction with [2]) gives the desired behavior and not too many specializations.
Thanks for your time! David
---- Links: [1] : https://ghc.haskell.org/trac/ghc/ticket/10972 [2] : https://ghc.haskell.org/trac/ghc/ticket/10971
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Nice work David!
I say put it under :info. This feature is very useful for beginners and we
can't expect them to know about some other info command, what it does, and
how it would help them. I too would probably not remember to use this if
it's hidden somewhere else.
Cheers,
Adam
On Mon, Oct 19, 2015 at 9:32 PM, Doug Burke
Or
When t is []: find :: (a -> Bool) -> [a] -> Maybe a
if this really is for the newcomer!
Doug
On Mon, Oct 19, 2015 at 3:11 PM Richard Eisenberg
wrote: I would avoid the `(t ~ []) =>` prefix -- it might be confusing to the newcomers this feature is meant to serve. How about
With t := []: find :: (a -> Bool) -> [a] -> Maybe a
?
Richard
On Oct 19, 2015, at 12:47 PM, David Kraeutmann
wrote: Hi,
I'm working on a GHC feature [1] that allows users to view specializations of functions like in (name subject to change)
----
:binfo find find :: Foldable t => (a -> Bool) -> t a -> Maybe a Specialisations: t ~ [] => find :: (a -> Bool) -> [a] -> Maybe a
:binfo first first :: Arrow a => a b c -> a (b, d) (c, d) Specialisations: a ~ (->) => first :: (b -> c) -> (b, d) -> (c, d)
Now there are two things left to decide on: * What command should the specializations be visible under? We can either put it under :info or make a special command :sinfo or :binfo that displays only the expression's type and specialisations like in the example above?
* What specializations do we want to display? goldfire suggested using the default list, which has the added benefit of being customizable by e.g. instructors, so adding a default Maybe (in conjunction with [2]) gives the desired behavior and not too many specializations.
Thanks for your time! David
---- Links: [1] : https://ghc.haskell.org/trac/ghc/ticket/10972 [2] : https://ghc.haskell.org/trac/ghc/ticket/10971
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Hi, David Kraeutmann wrote:
I'm working on a GHC feature [1] that allows users to view specializations of functions like in (name subject to change)
----
:binfo find find :: Foldable t => (a -> Bool) -> t a -> Maybe a Specialisations: t ~ [] => find :: (a -> Bool) -> [a] -> Maybe a
:binfo first first :: Arrow a => a b c -> a (b, d) (c, d) Specialisations: a ~ (->) => first :: (b -> c) -> (b, d) -> (c, d)
Looks very helpful. Three ideas: (1) I think this would be easier to read if the specialized type signature would come first. Maybe like this: find :: Foldable t => (a -> Bool) -> t a -> Maybe a Specializations: find :: (a -> Bool) -> [a] -> Maybe a -- if f ~ [] find :: (a -> Bool) -> Either b a -> Maybe a -- if f ~ Either b (2) Can this be made to work for expressions, too? $ :type-so-that-i-get-it find even find even :: (Foldable t, Integral a) => t a -> Maybe a Specializations: find even :: [Integer] -> Maybe Integer -- if t ~ [], a ~ Integer (3) Could the specializations also be shown in haddock documentation? Tillmann

On Oct 20, 2015, at 9:21 AM, Tillmann Rendel
Looks very helpful. Three ideas:
(1) I think this would be easier to read if the specialized type signature would come first. Maybe like this:
find :: Foldable t => (a -> Bool) -> t a -> Maybe a
Specializations:
find :: (a -> Bool) -> [a] -> Maybe a -- if f ~ [] find :: (a -> Bool) -> Either b a -> Maybe a -- if f ~ Either b
Yes -- I like this more, too.
(2) Can this be made to work for expressions, too?
$ :type-so-that-i-get-it find even find even :: (Foldable t, Integral a) => t a -> Maybe a
Specializations:
find even :: [Integer] -> Maybe Integer -- if t ~ [], a ~ Integer
I like this, too. And this example also brings up the possibility of a combinatorial number of specializations that could be printed. We'd want to limit it, I think.
(3) Could the specializations also be shown in haddock documentation?
Yes yes yes please please please. Richard
Tillmann _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
participants (5)
-
Adam Bergmark
-
David Kraeutmann
-
Doug Burke
-
Richard Eisenberg
-
Tillmann Rendel