so-dang-cool / z

Z is a Java library providing accessible, consistent function combinators.
MIT License
27 stars 0 forks source link

Currying types for deep fusions #19

Open booniepepper opened 3 years ago

booniepepper commented 3 years ago

A proper explanation is lacking, but...

Some sketches in Haskell of what I'm hoping to create:

Two "BiFunction"s combined

-- Single BiFunction
fused a b = f a b
fused = f

-- Two BiFunctions
fused a b c = g (f a b) c
fused = (g .) . f

fuse f g = (g .) . f
fuse = flip ((.) . (.))

-- Three BiFunctions
fused a b c d = h (g (f a b) c) d
fused = (((h .) . g) .) . f

fuse f g h = (((h .) . g) .) . f
fuse = flip (flip . (((.) . (.)) .) . flip ((.) . (.)))

-- Four BiFunctions
fused a b c d e = i (h (g (f a b) c) d) e
fused = (((((i .) . h) .) . g) .) . f

fused f g h i = (((((i .) . h) .) . g) .) . f
fuse = flip (flip . ((flip . (((.) . (.)) .)) .) . flip (flip . (((.) . (.)) .) . flip ((.) . (.))))

So, carve some time and see if there's a way to emulate a pattern like this in Java

booniepepper commented 3 years ago

See also:

https://github.com/hiljusti/z/tree/explore/currying-types