[Haskell-cafe] partial type annotations

Nicholas Tung ntung at ntung.com
Fri Jan 20 01:11:21 CET 2012

On Thu, Jan 19, 2012 at 15:02, Edward Z. Yang <ezyang at mit.edu> wrote:

> Oleg has described a grody hack which achieves this effect.
>    http://okmij.org/ftp/Haskell/types.html#partial-sigs
> I agree more first class support for this would be nice.
> Edward

That's an amusing hack, but does it provide anything on top of `asTypeOf`?
I'd rather write Oleg's first example as,

isOrd :: Ord a => a
isOrd = undefined
asOrd = flip asTypeOf isOrd

f x = Just $ asOrd x
-- now has type Ord a => a -> Maybe a

Actually, using view patterns, one can get closer to the code I wanted to

f (asOrd -> x) = Just x

comp x = do
    (asOrd -> y) <- return x
    return y

But, ideally, I want type expressions to appear as types, not value
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120119/978210ab/attachment.htm>

More information about the Haskell-Cafe mailing list