From: Roman Cheplyaka <r...@ro-che.info>
Date: Tue, 22 Mar 2011 08:50:33 +0200
Local: Tues, Mar 22 2011 2:50 am
Subject: Re: [loker] C representation and further plans
* Alexander Batischev <eual...@gmail.com> [2011-03-21 23:26:54+0200]
> On Mon, Mar 21, 2011 at 10:01:35PM +0200, Roman Cheplyaka wrote: Sorry, perhaps I was not clear. > > * Alexander Batischev <eual...@gmail.com> [2011-03-21 21:00:16+0200] > > > On Mon, Mar 21, 2011 at 08:25:35AM +0200, Roman Cheplyaka wrote: > > > > * Alexander Batischev <eual...@gmail.com> [2011-03-21 01:27:31+0200] > > > > > IR2C.hs:23:0: > > > > > Couldn't match expected type `ArrayNT CChar' > > > > > against inferred type `ArrayNT CString' > > > > > When generalising the type(s) for `translateStatement' > > > > That's my fault. If you look at C.hs, you'll find this line: > > > > type ExprType NULL = CString -- do we need NULL for anything else? > > > > Apparently we do! :) > > > I can't figure out how should I fix that. ExprType just binds internal > > > instance CExpr t => CExpr NULL > > > but I can't: > > > C.hs:88:33: Not in scope: type variable `t' > > > (so type variables should be used in the type signature - or it would be > > > Any advice? > > Yes -- you need to annotate the NULL datatype with its C type, just as > Still don't get it. I tried to declare new CNull type and add the > data CNull > instance CExpr NULL Currently we have data NULL = NULL Your problem is that in CExpr declaration you cannot infer the type of What you can do instead is add a type parameter to NULL: data NULL t = NULL (compare with CVariable declaration). Now the same data constructor NULL carries the information about its C type ExprType (NULL t) = t This technique is called phantom types[1]. [1]: http://www.haskell.org/haskellwiki/Phantom_type -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||