kasei / attean

A Perl Semantic Web Framework
19 stars 10 forks source link

First useful type and coercions #139

Closed kjetilk closed 4 years ago

kjetilk commented 4 years ago

This is in partial fulfillment of #138 , but it should be useful already, so I'm submitting a PR with it.

The next step is to have it coerce upon construction. That doesn't work yet (there are commented out tests about it).

I'm not quite sure how we'd do it, since we only require attributes in the API, I'm not sure where we set the coerce flag. It creates a to_AtteanIRI method that could be called also. We could also not coerce by default in the constructor, but instead do it in the helper methods, in this case in Attean::RDF::iri. So, there is a bunch of options. But I think this can be merged before that.

kasei commented 4 years ago

I'm a bit hesitant about the approach of defining things outside of the top-level Attean package. Is that commonly done for these sorts of Types helper classes? If that's just what the community does with these things, I guess I can get past my hesitation, but it feels really strange.

kjetilk commented 4 years ago

I'm not quite sure, but looking at some of the classes named Types, most that are named Foo::Types are Moose, whereas those that come after that it seems that since the introduction of Type::Tiny, it is conventional to put Types first. I don't really have a strong opinion about it, but it seems like the convention.