Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
ESLint rule for pure functions in Angular/typescript

Is there any ESLint rule for writing only pure functions in typescript? I wanted to write only pure functions in my code. Does anyone know how do we do this?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Purity Analysis is equivalent to solving the Halting Problem, and thus cannot be done statically in the general case. There will always be infinitely many functions for which your purity checker can neither prove that they are pure nor that they are impure.

Which means any possible purity checker can only do one of two things:

  • Play it safe, and reject any function for which it cannot positively prove that it is pure. This means there are infinitely many pure functions that the purity checker will not allow you to write.
  • Accept any function for which it cannot positively prove that it is impure. This means there are infinitely many impure functions that the purity checker will allow you to write.

The proper way to do this, really, is to design the language, the type system, and the libraries from the ground up to be 100% pure. Then, and only then, will you have a chance to automatically check for purity in a sensible way. It is of course still impossible to check in the general case, but designing the language, the type system, and the libraries to be easily checkable helps making the checker more useful.

The trivial case would be to design a language which doesn't allow you to write impure functions in the first place, but such a language would not be terribly useful. As one of the designers of Haskell has said: all that a pure program can do is make the CPU warm. To which someone from the audience responded: making the CPU warm is actually a side-effect, too!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda