[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

Dan Licata drl at cs.cmu.edu
Fri Jul 27 05:31:44 EDT 2007


On Jul26, apfelmus wrote:
> Yes, the types of the patterns don't unify. But each one is a
> specialization of the argument type. Note that the type signature is
> 
>   bar :: (forall a . ViewInt a => a) -> String
> 
> which is very different from
> 
>   bar :: forall a . ViewInt a => a -> String
> 
> Without the extension, we would write  bar  as follows
> 
>   bar :: (forall a . ViewInt a => a) -> String
>   bar x = let xNat = x :: Nat in
>      case xNat of
>        Zero -> ...
>        _    -> let xListBool = x :: [Bool] in
>           case xListBool of
>              True:xs -> ...
> 
> In other words, we can specialize the polymorphic argument to each
> pattern type and each equation may match successfully.

Oh, I understand what you're saying now.  Thanks for clarifying!
 
-Dan


More information about the Haskell-Cafe mailing list