DEV Community

Cover image for Type library kura meets built-in class.
kobaken
kobaken

Posted on

1

Type library kura meets built-in class.

https://metacpan.org/pod/kura

The type library kura now possible to use the Perl with built-in class. This allows you to gather objects and types.

use v5.40;
use experimental 'class';

class Fruit {
    use Exporter 'import';
    use Types::Common -types;

    # kura meets built-in class!
    use kura Name => StrLength[1, 255];

    field $name :param :reader;

    ADJUST {
        Name->assert_valid($name);
    }
}

my $fruit = Fruit->new(name => ''); # Error!
Enter fullscreen mode Exit fullscreen mode

This is a unique feature of kura, that isn't possible with Type::Library.

Feel free to give it a try!


This article is for Japanese Perl Advent Calendar 2024

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay