Remix.run Logo
calf 3 hours ago

What's the steelman argument though? Why do languages like Haskell have currying? I feel like that is not set out clearly in the argument.

mrkeen 14 minutes ago | parent | next [-]

I have a web backend with a top-level server that looks something like:

  ...

  :<|> collectionsServer compactor env registry
  :<|> queryServer qp sp struc registry warcFileReader logger
  :<|> indexationServer fetcher indexer

  ...
I.e. a request coming into the top-level server will go into the collections server or the query server or the indexation server. Each server is further broken down (collections has 4 routes, query has 4 routes, indexation has 5 routes.)

So lets try making the the arguments of just the collections server explicit. (It will take me too long to try to do them all.)

You can 'list' collections, 'delete' a collection, merge collectionA into collectionB, or get the directory where the collections live. So the input (the lambda term(s) we're trying to make explicit) can be () or (collectionName) or (collectionNameA, collectionNameB) or ().

In order to put these lambda terms explicitly into the source code, we need to add four places to put them, by replacing collectionsServer with the routes that it serves:

  ...

  :<|> (       listCollections registry
         :<|> (\collectionName -> deleteCollection env registry collectionName)
         :<|> (\collectionName1 collectionName2 -> mergeInto compactor collectionName1 collectionName2)
         :<|>  getCollectionDir env ) 
  :<|> queryServer qp sp struc registry warcFileReader logger
  :<|> indexationServer fetcher indexer

  ...
And now you know what explicit lambda terms collectionsServer takes!
emih 2 hours ago | parent | prev [-]

Mathematically it's quite pretty, and it gives you elegant partial application for free (at least if you want to partially apply the first N arguments).