RE: [Template-haskell] The ':' operation with patterns ?
Sean says : | Firstly, if we defined | | pcons :: Patt -> Patt -> Patt | pcons x xs = [p| $x : $xs |] | | as per the Template Haskell paper we get the error message | | MkZip.hs:23: Parse error in pattern Indeed, pattern splices are not implemented, nor are pattern quotes. Why not? Below is a message I sent to Tim about this. I'd be interested to know the thoughts of other TH folk. When I sent my message to Tim I was thinking about pattern splices in an expression context, thus (\ $p -> e). But Sean's difficulty shows how useful pattern quotes and splices might be to build bigger patterns: [p| $x : $xs |]. Indeed, I hadn't thought of that. I suppose it might be possible to allow pattern splices inside pattern quotes. Seems a bit weird and ad-hoc, though. I don't know how hard it would be to implement. Simon
participants (1)
-
Simon Peyton-Jones