News for hackers. Stuff that matters.
Re:Map, Filter, Reduce in Fortran (2019) by adgjlsfhk1 on Sunday January 01, 2023 @11:54AM (#34207986)
Am I missing something or does this implementation only work with integer functions. If you have to write your own mapreduce for every type, that kind of defeats the point.
Re:Map, Filter, Reduce in Fortran (2019) by j_m_b on Sunday January 01, 2023 @12:15PM (#34208256)
You're correct. However, you would create a library and make map an interface and create implementations for the types you need. e.g. https://github.com/wavebitscientific/functional-fortran/blob...
Re:Map, Filter, Reduce in Fortran (2019) by rpep on Sunday January 01, 2023 @02:55PM (#34210148)
That’s common to all typed languages and is the motivation behind generics/templates which allow you to write once and provide specialisation where necessary. In older C and Fortran libraries it wasn’t unusual to have to compile a library multiple times to support different input types - FFTW does this for example. Often there’s some macro magic with a variable injected at build time to determine the type.
Re:Map, Filter, Reduce in Fortran (2019) by msla on Sunday January 01, 2023 @04:55PM (#34211419)
> That’s common to all typed languages

It isn't. Haskell, for example, has a type system expressive enough to encode concepts such as "a function which takes an array of elements of any type (fixed at compile time) and another function which operates on elements of the type that array is composed of and returns an array of elements of that unnamed type" and it has a type system with fewer holes than any Algol-derived language's (Ada, C, Pascal) type system has.

Re:Map, Filter, Reduce in Fortran (2019) by User23 on Sunday January 01, 2023 @05:45PM (#34211879)
Algol 60’s type system has fewer holes than most Algol-derived languages.
Re:Map, Filter, Reduce in Fortran (2019) by msla on Sunday January 01, 2023 @06:07PM (#34212078)
> Algol 60’s type system has fewer holes than most Algol-derived languages.

And this can be a mixed blessing. If an inexpressive type system has few or no holes, it becomes a straitjacket where you can't write the kinds of perfectly well-defined functions you need because the type system can't express them. The classic pathological example is how Standard Pascal couldn't express the concept of a function which took an arbitrary-size array, but the example so common it's typically overlooked is how it's impossible in many Algol-derived languages to write one function to compare two numbers instead of having to write four or five such functions, especially if you're unwilling to let the type system hole of automatic integral and floating-point size promotion potentially introduce odd bugs.

Haskell's type system is strong and fairly expressive, with language extensions to make it more expressive.

(This does not change the fact type systems typically express the wrong things, but this post is long enough already.)

Re:Map, Filter, Reduce in Fortran (2019) by Volt on Sunday January 01, 2023 @06:20PM (#34212193)
You should literally continue reading the rest of the sentence.
Re:Map, Filter, Reduce in Fortran (2019) by msla on Sunday January 01, 2023 @07:05PM (#34212621)
Haskell doesn't have generics or templates, it has an expressive type system.
Re:Map, Filter, Reduce in Fortran (2019) by tpoacher on Monday January 02, 2023 @11:28AM (#34219756)
"Expressive Type System" without context is just a buzzword. In this particular context, it simply means that Haskell allows for types to be parameterised, which is a different way of saying it allows for generic types.
Re:Map, Filter, Reduce in Fortran (2019) by enriquto on Sunday January 01, 2023 @04:53PM (#34211387)
There are not too many types to begin with. Ints and floats and that's pretty much it.
Re:Map, Filter, Reduce in Fortran (2019) by marshallward on Sunday January 01, 2023 @06:21PM (#34212211)
True but every kind is considered a type.
Re:Map, Filter, Reduce in Fortran (2019) by gylterud on Sunday January 01, 2023 @06:34PM (#34212348)
Fortran will get generics soon(ish).