Grokbase
x

Re: Maybe[Foo] type coercions

View PostFlat  Thread  Threaded | Next >
Hans Dieter Pearcey Re: Maybe[Foo] type coercions
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Excerpts from Jesse Luehrs's message of Mon Feb 15 19:31:24 -0500 2010:
> I'm not sure what problem you're having, since you didn't post the
> error message, but you probably need the attribute definition to happen
> after the types are defined... pretty sure this would assume you have a
> class named 'MaybeDateTime'.

Correct.

> > subtype 'DateTime' => as 'Object' => where { $_->isa('DateTime') };
>
> Also, this is equivalent to "class_type 'DateTime'".
>
> > subtype 'MaybeDateTime'
> >     => as 'Maybe[Object]'
> > => where { $_->isa('DateTime') or not defined $_ };

And this is "subtype 'MaybeDateTime', as 'Maybe[DateTime]'".

hdp.

Thread : Maybe[Foo] type coercions
1)
Hans Dieter Pearcey Excerpts from Jesse Luehrs's message of Mon Feb 15 19:31:24 -0500 2010: Correct. And this is...
2)
Karen Etheridge I'm having difficulty getting a type coercion to work that involves Maybes. I've looked at the...
spacer
View PostFlat  Thread  Threaded | Next >
Home > Groups > Moose > Maybe[Foo] type coercions (1 post) > View Post