#4798: Make HsIf more polymorphic with RebindableSyntax
---------------------------------+------------------------------------------
Reporter: nsch | Owner: nsch
Type: feature request | Status: new
Priority: normal | Component: Compiler (Type checker)
Version: 7.0.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Currently, ifThenElse is typed this way:
{{{
ifThenElse :: pred_ty -> b_ty -> b_ty -> res_ty
}}}
I propose to change this to:
{{{
ifThenElse :: pred_ty -> b1_ty -> b2_ty -> res_ty
}}}
to support expressions like this:
{{{
ifThenElse :: Maybe a -> (a -> b) -> b -> b
ifThenElse (Just a) f _ = f a
ifThenElse Nothing _ e = e
example :: String
example = if Just 2
then \v -> show v
else "No value"
}}}
The fix is very simple and just one more line to add to the typechecker.
Patch is attached.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4798>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs