I like the calls and resolves! Nice. On Monday, November 6, 2017 at 8:45:48 PM UTC-8, David Andrews wrote: > > Sorry I misread your example as a single list argument. > > Strictly speaking, you can not call a function with no arguments in Elm, > but some functions take Unit as an argument. > > There are a couple of roadblocks preventing this exact functionality in > Elm. Firstly, Elm does not allow recursive types > <https://ellie-app.com/5YDsxhFLSa1/0>. Secondly, a name in Elm must have > the same type everywhere it is mentioned. Even normal function > overloading is not possible <https://ellie-app.com/5YDsxhFLSa1/1> without > renaming the function. > > The closest I could come up with was this > <https://ellie-app.com/g4DpfMDxPa1/1>, which I don't think will be very > satisfactory to you, but I believe is isomorphic to the Haskell example. > You just have to explicitly name all of the function applications in Elm. > > > On Nov 6, 2017 11:53 AM, "Ray Toal" <[email protected] <javascript:>> > wrote: > > Thanks but I was looking not for the obvious, practical approach for > summing integers but was interested in the puzzle of arbitrary-length > currying. When called with no arguments, the function should yield its sum > so far. When called with a single argument, the function should return a > function that knows about what it has seen so far. It sounds stateful, but > can be done without state. But since Elm is statically typed and doesn't > have overloading, I'm wondering if this can even be done with currying. > > > On Monday, November 6, 2017 at 4:23:21 AM UTC-8, David Andrews wrote: > >> The solution for the list version is very straightforward in elm: >> https://ellie-app.com/g4DpfMDxPa1/0 >> >> On Sun, Nov 5, 2017 at 10:39 PM, Ray Toal <[email protected]> wrote: >> >>> 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 >>> >>> >>> >>> -- >>> 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 [email protected]. >>> >>> 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 [email protected] <javascript:>. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
