Closed ezmiller closed 2 years ago
@genmeblog just a reminder to take a look at this when you get a chance. :)
I did a review. I see mainly one issue with changing typeof
contract. The other two are just optimization proposals.
@genmeblog: I changed things here so that:
types
- returns the set concrete types;general-types
returns the set of general types;typeof
returns the concrete type of the column;typeof?
can validate the concrete or general type of a column; and,general-types-lookup
table.@genmeblog if you have a moment, would you like to take another look at this?
Goal
In #71 , @genmeblog pointed out that there's a type hierarchy in the
tablecloth.api.utils
namespace. Following some discussion in #73 , this PR aims to set up a type interface where users mainly interact the types of elements in a column in terms of the "general" (rather than concrete) types. In other words, a user will want to know if an array has:integer
rather than:int64
values.Solution
I added some new functions in
tablecloth.api.utils
to help work with the type hierarchytablecloth.api.utils/type-sets
:->general-types
- Given a concrete type this function returns the set of general types, e.g.:(->general-types :int64) ;; => #{:integer :numerical}
types
- Returns the set of general types, i.e. the keys oftablecloth.api.utils/type-sets
concrete-types
- Returns the set of concrete types, i.e. the types that TMD uses.concrete-type?
- Returns true if the given type is a concrete type.Then I adjusted
typeof
andtypeof?
to use this hierarchy, so now:typeof?
- Will return true if the elements of the given column match the given general type or concrete typetypeof
- Returns the set of general types that describe the concrete type of the elements of the columnPlease see the tests in this PR for examples.
Open Questions
tablecloth.api.utils/type-sets
?typeof?
also to support concrete types?