-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Homogeneous and HomogeneousRowList for homogeneous rows #20
Changes from 3 commits
8b39b00
17d4228
0d25ad4
3d51ac4
6d179f8
20fdbe6
fe087b6
632538d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,10 @@ module Type.Row | |
, class ListToRow | ||
) where | ||
|
||
|
||
import Type.Equality (class TypeEquals) | ||
|
||
|
||
data RProxy (row :: # Type) = RProxy | ||
|
||
-- Must not be exported | ||
|
@@ -70,3 +74,17 @@ instance listToRowCons | |
:: ( ListToRow tail tailRow | ||
, RowCons label ty tailRow row ) | ||
=> ListToRow (Cons label ty tail) row | ||
|
||
-- | Ensure that every field in a row has the same type. | ||
class Homogeneous (row :: # Type) fieldType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add a comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a value-level function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I though I'd asked this already but can't see it now. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think so |
||
instance homogeneous | ||
:: ( RowToList row fields | ||
, FieldOf fields fieldType ) | ||
=> Homogeneous row fieldType | ||
|
||
class FieldOf (rowList :: RowList) fieldType | rowList -> fieldType | ||
instance fieldOfCons | ||
:: ( FieldOf tail fieldType | ||
, TypeEquals fieldType fieldType2 ) | ||
=> FieldOf (Cons symbol fieldType tail) fieldType2 | ||
instance fieldOfNil :: FieldOf Nil fieldType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also missing a functional dependency here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct in thinking that the right thing to do here is
| row -> fieldType
?