Skip Menu |

This queue is for tickets about the MooseX-Types CPAN distribution.

Report information
The Basics
Id: 41191
Status: resolved
Priority: 0/
Queue: MooseX-Types

People
Owner: Nobody in particular
Requestors: t0m [...] state51.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug, or am I failing to get it?
Date: Mon, 24 Nov 2008 17:47:04 +0000
To: bug-MooseX-Types [...] rt.cpan.org
From: Tomas Doran <t0m [...] state51.co.uk>
I'm quite sure that this is probably user error, but the following doesn't work for me currently: package MyTypes; use MooseX::Types::Moose qw/ Str /; use MooseX::Types -declare => [qw/ FooType /]; subtype FooType => as Str => where { 1 }; package MyClass; use Moose; use MyTypes qw/FooType/; has foo => ( isa => FooType ); package main; use MyClass; MyClass->new(foo => 'moo'); What am I doing wrong? Cheers t0m
Subject: Re: [rt.cpan.org #41191] Bug, or am I failing to get it?
Date: Sat, 6 Dec 2008 17:24:24 +0000
To: "t0m [...] state51.co.uk via RT" <bug-MooseX-Types [...] rt.cpan.org>
From: Matt S Trout <mst [...] shadowcat.co.uk>
On Mon, Nov 24, 2008 at 12:48:43PM -0500, t0m@state51.co.uk via RT wrote: Show quoted text
> Mon Nov 24 12:48:17 2008: Request 41191 was acted upon. > Transaction: Ticket created by t0m@state51.co.uk > Queue: MooseX-Types > Subject: Bug, or am I failing to get it? > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: t0m@state51.co.uk > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41191 > > > > I'm quite sure that this is probably user error, but the following > doesn't work for me currently: > > package MyTypes; > use MooseX::Types::Moose qw/ Str /; > use MooseX::Types -declare => [qw/ FooType /]; > > subtype FooType => as Str => where { 1 };
parses to subtype "FooType", as "Str", where { 1 }; because of the fat comma stringifying to the left. You wanted subtype FooType, as Str, where { 1 }; -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
From: jjn1056 [...] yahoo.com
On Sat Dec 06 12:24:35 2008, mst@shadowcat.co.uk wrote: Show quoted text
> On Mon, Nov 24, 2008 at 12:48:43PM -0500, t0m@state51.co.uk via RT wrote:
> > Mon Nov 24 12:48:17 2008: Request 41191 was acted upon. > > Transaction: Ticket created by t0m@state51.co.uk > > Queue: MooseX-Types > > Subject: Bug, or am I failing to get it? > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: t0m@state51.co.uk > > Status: new > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=41191 > > > > > > > I'm quite sure that this is probably user error, but the following > > doesn't work for me currently: > > > > package MyTypes; > > use MooseX::Types::Moose qw/ Str /; > > use MooseX::Types -declare => [qw/ FooType /]; > > > > subtype FooType => as Str => where { 1 };
> > parses to > > subtype "FooType", as "Str", where { 1 }; > > because of the fat comma stringifying to the left. You wanted > > subtype FooType, as Str, where { 1 }; >
If you are attached to the '=>' as I am, since it's a bit more visible in my editor (I tend to use tiny fonts so I can see lots of code) you can do: subtype FooType() => as Str .....; and that will also work. I'm adding docs to this effect in the next version and probably will move up the note regarding the '=>' stringification issue so that it's more clear. I realize all the Moose core docs regarding type constraints use this so it's a bit of switch if you are used to one type of syntax. I would welcome any patches or thoughts how to make this 'just work' to smooth the path a bit. Thanks for the bug report.