News for hackers. Stuff that matters.
Re:Optimizing Guile Scheme by Iceland_jack on Thursday September 26, 2024 @11:55AM (#41659913)
lift = sequenceA @[] @(a ->)
Re:Optimizing Guile Scheme by Y_Y on Thursday September 26, 2024 @12:54PM (#41660640)
Did you do that by hand? I guessed you used the classic `pointfree` program, bit that gave

    lift = fix ((`ap` tail) . (. head) . flip ((.) . liftM2 (:)))
As far as I know it's not possible to get this functionality in Haskell even with clever instance magic, but I'd love to be proved wrong.
Re:Optimizing Guile Scheme by Iceland_jack on Saturday September 28, 2024 @04:47AM (#41678890)
> As far as I know it's not possible to get this functionality in Haskell even with clever instance magic

It is possible to fill in basic function bodies based on their type, using ghc-justdoit (https://hackage.haskell.org/package/ghc-justdoit). That's maybe not what you meant, if you are looking for integrating pointfree into Haskell it can be added to ghci or your development environment.

    foo :: ((a -> r) -> r) -> (a -> ((b -> r) -> r)) -> ((b -> r) -> r)
    foo = (…)
In this case I wrote it because I knew about the pattern. Your lift definition is just ($)

      flip \a -> ($ a)
    = flip (&)
    = flip (flip ($))
    = ($)
Re:Optimizing Guile Scheme by Iceland_jack on Saturday September 28, 2024 @04:52AM (#41678910)
Maybe you meant to write

    (??) :: Functor f => f (a -> b) -> a -> f b
    funs ?? a = fmap ($ a) funs
from lens: https://hackage.haskell.org/package/lens-5.3.2/docs/Control-...

This is valid definition of lift along a different, less interesting but more general axis.

    lift = (??) @[]
Re:Optimizing Guile Scheme by Y_Y on Friday September 27, 2024 @03:51AM (#41667478)

    lift = flip $ \a -> ($a)