{"id":16302238,"url":"https://github.com/kaiepi/ra-data-record","last_synced_at":"2025-10-25T13:32:03.436Z","repository":{"id":47202283,"uuid":"249544509","full_name":"Kaiepi/ra-Data-Record","owner":"Kaiepi","description":"Record types!","archived":false,"fork":false,"pushed_at":"2022-09-17T18:50:57.000Z","size":219,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T07:22:19.514Z","etag":null,"topics":["data","raku","record","records","sanitization","type","types"],"latest_commit_sha":null,"homepage":null,"language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kaiepi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-23T21:08:45.000Z","updated_at":"2022-09-12T09:39:18.000Z","dependencies_parsed_at":"2023-01-18T13:30:17.715Z","dependency_job_id":null,"html_url":"https://github.com/Kaiepi/ra-Data-Record","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiepi%2Fra-Data-Record","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiepi%2Fra-Data-Record/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiepi%2Fra-Data-Record/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiepi%2Fra-Data-Record/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kaiepi","download_url":"https://codeload.github.com/Kaiepi/ra-Data-Record/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238155205,"owners_count":19425665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data","raku","record","records","sanitization","type","types"],"created_at":"2024-10-10T20:56:49.760Z","updated_at":"2025-10-25T13:31:58.108Z","avatar_url":"https://github.com/Kaiepi.png","language":"Raku","readme":"![Build Status](https://github.com/Kaiepi/ra-Data-Record/actions/workflows/test.yml/badge.svg)\n\nNAME\n====\n\nData::Record - Record types!\n\nSYNOPSIS\n========\n\n```perl6\nuse Data::Record;\n\n# Data::Record introduces record types for maps, lists, and tuples:\nmy constant Schema = {@\n    name  =\u003e Str:D,\n    items =\u003e [@ \u003c@ Int:D, Str:D @\u003e @]\n@} :name('Schema');\n\n# With the type we just made, we can typecheck data structures to ensure they\n# match it:\nmy %valid =\n    name  =\u003e 'Kaiepi',\n    items =\u003e [(1, 'Item 1'), (2, 'Item 2')];\nmy %invalid =\n    name        =\u003e 'Mrofnet',\n    items       =\u003e [],\n    constructor =\u003e 'Thanks, JavaScript.';\nsay %valid ~~ Schema;   # OUTPUT: True\nsay %invalid ~~ Schema; # OUTPUT: False\n\n# ...but typechecking this way is inefficient, and is always done eagerly!\n# Using the (\u003c\u003c), (\u003e\u003e), (\u003c\u003e), and (\u003e\u003c) operators provided, data can be coerced\n# to our record type by various means:\n%valid   := %valid (\u003e\u003c) Schema;\n%invalid := %invalid (\u003c\u003c) Schema;\nsay %invalid; # OUTPUT: {items =\u003e [], name =\u003e Mrofnet}\n\n# For the most part, coerced data can be used the same way as the original\n# data, with the bonus of extra typechecking:\n{\n    CATCH { default { say .^name } }\n    %invalid\u003citems\u003e.push: (3, 'Item 3');        # OK!\n    %invalid\u003citems\u003e.push: \"OOPSIE WOOPSIE OwO\"; # OUTPUT: X::Data::Record::TypeCheck\n}\n\n# Finally, to restore the data's original typing, simply call the unrecord\n# method on it:\nmy %now-valid := %invalid.unrecord;\nsay %now-valid.^name;           # OUTPUT: Hash\nsay %now-valid\u003citems\u003e.^name;    # OUTPUT: Array\nsay %now-valid\u003citems\u003e[0].^name; # OUTPUT: List\n```\n\nDESCRIPTION\n===========\n\n`Data::Record` is a library that adds support for record types to Raku. Operators for creating record types for maps, lists, and tuples are included. Data structures can then be coerced to these record types using the coercion operators provided, some of which will sanitize them, all of which allow for efficient typechecking for common operations you can do with them.\n\nFor documentation on how this library can be used, refer to the [wiki](https://github.com/Kaiepi/p6-Data-Record/wiki/).\n\nAUTHOR\n======\n\nBen Davies (Kaiepi)\n\nCOPYRIGHT AND LICENSE\n=====================\n\nCopyright 2022 Ben Davies\n\nThis library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaiepi%2Fra-data-record","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaiepi%2Fra-data-record","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaiepi%2Fra-data-record/lists"}