RE: Newtype wrappers in hsSyn

2010-02-03 Thread Simon Peyton-Jones
| I was wondering whether there would be any concerns against redefining the | above type synonyms into newtypes? Either each one of the above gets its own | newtype wrapper or new phase-describing wrappers: | | newtype PostTc a = PostTc a deriving (Eq, Ord, Show, Functor) | newtype PostRn a =

Re: Newtype wrappers in hsSyn

2010-01-28 Thread Simon Marlow
On 28/01/2010 00:26, Simon Peyton-Jones wrote: |> type PostTcType = Maybe Type |> |> Now you're representing the data that isn't there by a Nothing, rather |> than a _|_. You could even newtype it and have fromPostTcType be |> equivalent to fromJust with a helpful error about the ordering. It

RE: Newtype wrappers in hsSyn

2010-01-27 Thread Simon Peyton-Jones
| > type PostTcType = Maybe Type | > | > Now you're representing the data that isn't there by a Nothing, rather | > than a _|_. You could even newtype it and have fromPostTcType be | > equivalent to fromJust with a helpful error about the ordering. It | > will be slower than what's currently there,

Re: Newtype wrappers in hsSyn

2010-01-27 Thread Neil Mitchell
Hi > I know Uniplate.  But there are two issues: > >  1. SYB will start using the table trick soon from what I hear, so I hope it > won't be too slow. That would be cool - although I do wonder how it can be done with the very general type of everywhere/everything. If you restrict the types (like

Re: Newtype wrappers in hsSyn

2010-01-27 Thread Thomas Schilling
On 27 Jan 2010, at 18:17, Neil Mitchell wrote: > Hi >>> | These have always distressed me. Would it be feasible to refactor so >>> | that this isn't necessary, e.g. >>> | >>> | typecheck :: HsSyn Name () -> HsSyn Name PostTcInfo > >> The problem is that these annotations tend to be construct

Re: Newtype wrappers in hsSyn

2010-01-27 Thread Neil Mitchell
Hi >> | These have always distressed me. Would it be feasible to refactor so >> | that this isn't necessary, e.g. >> | >> |     typecheck :: HsSyn Name () -> HsSyn Name PostTcInfo > The problem is that these annotations tend to be constructor-specific. You > might get it to work with GADTs, but I

Re: Newtype wrappers in hsSyn

2010-01-27 Thread Thomas Schilling
On 27 Jan 2010, at 15:12, Simon Peyton-Jones wrote: > > | I was wondering whether there would be any concerns against redefining the > | above type synonyms into newtypes? Either each one of the above gets its > own > | newtype wrapper or new phase-describing wrappers: > | > | newtype PostTc

Re: Newtype wrappers in hsSyn

2010-01-27 Thread Ian Lynagh
On Wed, Jan 27, 2010 at 02:38:25PM +, Thomas Schilling wrote: > > The Haskell AST used by GHC unfortunately has a few fields that are only > defined after certain phases have been run. For example: > > PostTcType, PostTcExpr -- only defined after type checking > SyntaxExpr, Fixity -

Newtype wrappers in hsSyn

2010-01-27 Thread Thomas Schilling
Hi, [This question is probably mostly for Simon PJ.] The Haskell AST used by GHC unfortunately has a few fields that are only defined after certain phases have been run. For example: PostTcType, PostTcExpr -- only defined after type checking SyntaxExpr, Fixity -- only defined after ren