Ray Toal

2017-11-06 03:39:56 UTC

There's an interesting problem on the Programming Puzzles and Stack

Exchange on arbitrary length currying

here: https://codegolf.stackexchange.com/questions/117017/arbitrary-length-currying.

It asks for a function f behaving as follows:

f () = 0

f (3)(9)(2)() = 14

This is trivial in dynamically typed languages that don't care about the

number of arguments, and is easy to do in statically typed languages which

allow overloading. But what about the ML-like languages?

The only ML-like language with a solution is Haskell. Its author says "Forcing

Haskell's strict type system to allow this requires some magic, namely,

enabling the GHC extension for flexible typeclass instances."

Is this problem impossible in Elm?

If impossibie, can a solution be found to a related problem, say where the

arguments are lists?, e.g.

f [] = 0

f [3] [9] [2] [] = 14

Exchange on arbitrary length currying

here: https://codegolf.stackexchange.com/questions/117017/arbitrary-length-currying.

It asks for a function f behaving as follows:

f () = 0

f (3)(9)(2)() = 14

This is trivial in dynamically typed languages that don't care about the

number of arguments, and is easy to do in statically typed languages which

allow overloading. But what about the ML-like languages?

The only ML-like language with a solution is Haskell. Its author says "Forcing

Haskell's strict type system to allow this requires some magic, namely,

enabling the GHC extension for flexible typeclass instances."

Is this problem impossible in Elm?

If impossibie, can a solution be found to a related problem, say where the

arguments are lists?, e.g.

f [] = 0

f [3] [9] [2] [] = 14

--

You received this message because you are subscribed to the Google Groups "Elm Discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups "Elm Discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.