kongware / scriptum

Functional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
MIT License
383 stars 21 forks source link

Ad-hoc polymorphic `foldr` yields an invalid type #315

Closed ivenmarquardt closed 3 years ago

ivenmarquardt commented 3 years ago

If we apply foldr to List.Foldable

export const foldr = fun(
  Foldable => f => acc => tx =>
    Foldable.foldMapr(Endo.Monoid) (f) (tx) (acc),
  "Foldable<t> => (a => b => b) => b => t<a> => b");

the unified type is (a => b => b) => b => List => b instead of (a => b => b) => b => List<a> => b.

ivenmarquardt commented 3 years ago

Partially applied type constructors were not taken into account in every case. Done.