[Haskell-cafe] partial type annotations
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.
> I agree more first class support for this would be nice.
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
But, ideally, I want type expressions to appear as types, not value
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe