|
From: Christopher St J. <cks...@gm...> - 2008-04-06 15:21:25
|
I see that the project has moved to Google code, but I didn't any
mailing lists there, is this list still active? I'll give it a shot...
I'm using HOC from the google code subversion repository on
OS X 10.4.11 with ghc 6.8.2. I'm running through some exercises
in the HIllegass Cocoa Programming book. I'm trying to create
a custom view that has a designated initializer like this:
- (id)initWithFrame:(NSRect)rect
{
if( self = [super initWithFrame:rect] ) {
...
}
return self;
}
I have the class ("StetchView") implemented in Haskell, and,
with the exception of the initializer, it runs:
$(declareClass "StretchView" "NSView")
$(exportClass "StretchView" "sv_" [
InstanceVariable "path" [t| Maybe (NSBezierPath ()) |]
[| Nothing |],
InstanceMethod 'drawRect,
InstanceMethod 'initWithFrame,
InstanceMethod 'windowNibName
])
I've got the initializer looking like this (I was trying to cut
it down to the absolute minimum):
sv_initWithFrame rect self = do
return self
But that doesn't work, see below for what happens.
Thanks for any help/hints/suggestions-to-chuck-it-all-I'm-crazy,
etc, etc.
-cks
----------8<----------8<----------8<----------
ckspb:~/distributopia/twasker cks$ make
mkdir -p build
ghc -XTemplateHaskell --make -fglasgow-exts -fth -odir build -hidir
build Main.hs -O hoctest0g
[146 of 149] Compiling StretchView ( StretchView.hs, build/StretchView.o )
Loading package base ... linking ... done.
Loading package array-0.1.0.0 ... linking ... done.
Loading package packedstring-0.1.0.0 ... linking ... done.
Loading package containers-0.1.0.1 ... linking ... done.
Loading package pretty-1.0.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package bytestring-0.9.0.1 ... linking ... done.
Loading package mtl-1.1.0.0 ... linking ... done.
Loading package parsec-2.1.0.0 ... linking ... done.
Loading package fgl-5.4.1.1 ... linking ... done.
Loading package binary-0.4.1 ... linking ... done.
Loading package old-locale-1.0.0.0 ... linking ... done.
Loading package old-time-1.0.0.0 ... linking ... done.
Loading package filepath-1.1.0.0 ... linking ... done.
Loading package directory-1.0.0.0 ... linking ... done.
Loading package unix-2.3.0.0 ... linking ... done.
Loading package HOC-1.0 ... linking ... done.
StretchView.hs:11:2:
Couldn't match expected type `NewlyAllocated (StretchView ())'
against inferred type `StretchView ()'
Expected type: ImpType_initWithFrame
(StretchView ()) (StretchView ())
Inferred type: NSRect -> StretchView () -> IO (StretchView ())
In a 'do' expression:
result[ahnn] <- sv_initWithFrame ::
ImpType_initWithFrame (StretchView ())
(StretchView ())
arg1 self
In the expression:
do result[ahnn] <- sv_initWithFrame ::
ImpType_initWithFrame (StretchView ())
(StretchView ())
arg1 self
HOC-1.0:HOC.Invocation.recordHOCEvent
HOC-1.0:HOC.Invocation.kHOCAboutToExportResult args
HOC-1.0:HOC.Invocation.setMarshalledRetval
(HOC-1.0:HOC.SelectorMarshaller.selectorInfoResultRetained
info_initWithFrame)
ret
result[ahnn]
make: *** [hoctest0g] Error 1
--
Christopher St. John
http://artofsystems.blogspot.com
|
|
From: Judah J. <jud...@gm...> - 2008-04-06 19:28:43
|
On Sun, Apr 6, 2008 at 8:21 AM, Christopher St John <cks...@gm...> wrote:
> I see that the project has moved to Google code, but I didn't any
> mailing lists there, is this list still active? I'll give it a shot...
>
> I'm using HOC from the google code subversion repository on
> OS X 10.4.11 with ghc 6.8.2. I'm running through some exercises
> in the HIllegass Cocoa Programming book. I'm trying to create
> a custom view that has a designated initializer like this:
>
> - (id)initWithFrame:(NSRect)rect
> {
> if( self = [super initWithFrame:rect] ) {
> ...
> }
> return self;
> }
>
> I have the class ("StetchView") implemented in Haskell, and,
> with the exception of the initializer, it runs:
>
> $(declareClass "StretchView" "NSView")
>
> $(exportClass "StretchView" "sv_" [
> InstanceVariable "path" [t| Maybe (NSBezierPath ()) |]
> [| Nothing |],
> InstanceMethod 'drawRect,
> InstanceMethod 'initWithFrame,
> InstanceMethod 'windowNibName
> ])
>
> I've got the initializer looking like this (I was trying to cut
> it down to the absolute minimum):
>
> sv_initWithFrame rect self = do
> return self
>
> But that doesn't work, see below for what happens.
I think you need the following (untested, but I confirmed that it typechecks):
sv_initWithFrame rect self = do
initWithFrame rect (super self)
-- any other custom initialization code goes here
Note that this corresponds to the call to [super initWithFrame:rect]
in the Objective-C code you posted above.
Hope that helps,
-Judah
|
|
From: Judah J. <jud...@gm...> - 2008-04-06 20:34:38
|
On Sun, Apr 6, 2008 at 12:28 PM, Judah Jacobson
<jud...@gm...> wrote:
> On Sun, Apr 6, 2008 at 8:21 AM, Christopher St John <cks...@gm...> wrote:
> > I see that the project has moved to Google code, but I didn't any
> > mailing lists there, is this list still active? I'll give it a shot...
> >
> > I'm using HOC from the google code subversion repository on
> > OS X 10.4.11 with ghc 6.8.2. I'm running through some exercises
> > in the HIllegass Cocoa Programming book. I'm trying to create
> > a custom view that has a designated initializer like this:
> >
> > - (id)initWithFrame:(NSRect)rect
> > {
> > if( self = [super initWithFrame:rect] ) {
> > ...
> > }
> > return self;
> > }
> >
> > I have the class ("StetchView") implemented in Haskell, and,
> > with the exception of the initializer, it runs:
> >
> > $(declareClass "StretchView" "NSView")
> >
> > $(exportClass "StretchView" "sv_" [
> > InstanceVariable "path" [t| Maybe (NSBezierPath ()) |]
> > [| Nothing |],
> > InstanceMethod 'drawRect,
> > InstanceMethod 'initWithFrame,
> > InstanceMethod 'windowNibName
> > ])
> >
> > I've got the initializer looking like this (I was trying to cut
> > it down to the absolute minimum):
> >
> > sv_initWithFrame rect self = do
> > return self
> >
> > But that doesn't work, see below for what happens.
>
> I think you need the following (untested, but I confirmed that it typechecks):
>
>
> sv_initWithFrame rect self = do
> initWithFrame rect (super self)
> -- any other custom initialization code goes here
>
> Note that this corresponds to the call to [super initWithFrame:rect]
> in the Objective-C code you posted above.
>
> Hope that helps,
> -Judah
>
Sorry, I was wrong above. The correct code would be:
sv_initWithFrame rect self = do
self' <- fmap castObject $ initWithFrame rect (super self)
-- Run any custom initialization on self'
return self'
-Judah
|