Skip to content

Commit 979f06a

Browse files
paulyoungpaf31
authored andcommitted
Add Homogeneous and HomogeneousRowList for homogeneous rows (#20)
* Add RecordOf and FieldOf for homogeneous records * Rename to `Homogenous` and move to `Row` type * Add `TypeEquals` constraint on field type * Add funcitonal dependency for `FieldOf` * Add comment explaining Homogeneous class * Add missin fun dep * Add Type.Row.Homogeneous * Remove unwanted comment That was incorrectly copied by the PureScript Emacs layer. * Rename `FieldOf` to `HomogenousRowList` To better communicate which class should be used in regular code. * Rename instances to coincide previous renaming
1 parent f7385cc commit 979f06a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Type/Row/Homogeneous.purs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Type.Row.Homogeneous
2+
( class Homogeneous
3+
, class HomogenousRowList
4+
) where
5+
6+
import Type.Equality (class TypeEquals)
7+
import Type.Row (class RowToList, Cons, Nil, kind RowList)
8+
9+
-- | Ensure that every field in a row has the same type.
10+
class Homogeneous (row :: # Type) fieldType | row -> fieldType
11+
instance homogeneous
12+
:: ( RowToList row fields
13+
, HomogenousRowList fields fieldType )
14+
=> Homogeneous row fieldType
15+
16+
class HomogenousRowList (rowList :: RowList) fieldType | rowList -> fieldType
17+
instance homogenousRowListCons
18+
:: ( HomogenousRowList tail fieldType
19+
, TypeEquals fieldType fieldType2 )
20+
=> HomogenousRowList (Cons symbol fieldType tail) fieldType2
21+
instance homogenousRowListNil :: HomogenousRowList Nil fieldType

0 commit comments

Comments
 (0)