Hey folks, I’m modeling a high-level, project-specific editable table view function, and I’m facing a type challenge when modeling the columns input types:
type alias Column record msg comparable selectType =
{ header : String
, sortable : Maybe (record -> comparable)
, content : CellContent record selectType
}
type CellContent record selectType
= Text { toLabel : record -> String }
| Select
{ options : List selectType
, selected : Maybe selectType
, toLabel : selectType -> String
}
editableTable :
{ records : Array record
, columns : List (Column record msg comparable selectType)
, canReorder : Bool
, state : Model
}
-> Html msg
editableTable config =
Debug.todo "editableTable"
The problem I’m facing is in CellContent
> Select
> options
Notice how it’s introducing a type variable. There are multiple problems with this type variable. If the user of this table needs to have multiple Select columns, they’ll all need to be of the same type. If the user of this table does not need a Select type of a column, then this type variable will be an unnecessary extra in the table type.
My goal is to abstract as high as possible, and as delightful as possible.
Help?
: )