[Haskell-cafe] Displaying specializations in :info or separately?
Tillmann Rendel
rendel at informatik.uni-tuebingen.de
Tue Oct 20 13:21:24 UTC 2015
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
More information about the Haskell-Cafe
mailing list