Questions tagged [row-polymorphism]
7 questions
6
votes
2 answers
Purescript Union of Rows
I've been trying to develop a component system in Purescript, using a Component typeclass which specifies an eval function. The eval function for can be recursively called by a component for each sub-component of the component, in essence fetching…

Joseph Young
- 2,758
- 12
- 23
5
votes
1 answer
Combining parametric polymorphism and polymorphic variants (backtick types)
Suppose I have a type consisting of multiple polymorphic variants (covariantly) such as the following:
[> `Ok of int | `Error of string]
Let's further suppose that I want to factor this definition into some kind of type constructor and a concrete…

Greg Nisbet
- 6,710
- 3
- 25
- 65
4
votes
4 answers
infer a type for common fields in two records
Bear with me if this is a foolish question. How can I type a generic function that takes two records and returns an array of their common fields?
Let's say I have:
type A = { name :: String, color :: String }
type B = { name :: String, address ::…

Sam R.
- 16,027
- 12
- 69
- 122
2
votes
1 answer
Define `type alias` with a partial definition or default
Is there a way to DRY this?
I don’t want to repeat contents : List Nav and wrapperId : String
type alias InputModel =
{ contents : List Nav
, containerClassName : Maybe String
, wrapperId : String
}
type alias Model =
{…

Kirk Strobeck
- 17,984
- 20
- 75
- 114
1
vote
1 answer
Can I specify that a type is an arbitrary record?
I have a type
type alias WithStatus l =
{ l
| status :
Status
}
This extends a record with a status field.
Now I'd like to make a function that takes a record and gives it a particular status, so I made:
addStatus : Status -> l ->…

Wheat Wizard
- 3,982
- 14
- 34
0
votes
1 answer
How to parse row-polymorphic records with SimpleJSON in PureScript?
I wrote a utility type and function that is meant to aid in parsing certain row-polymorphic types (sepcifically, in my case, anything that extends BaseIdRows:
type IdTypePairF r = (identifier :: Foreign, identifierType :: Foreign |…

bbarker
- 11,636
- 9
- 38
- 62
0
votes
1 answer
Looking for a type that is polymorphic in record fields (static duck typing)
I am looking for a type that is polymorphic in record fields so that it accepts records containing more fields with the constrain that all involved records coincide in these extra fields:
type foo = { first: string, last: string };
const o = {…
user5536315