简体   繁体   中英

data types and structures in functional programming and associated behaviours

After much reading on functional programming and lambda calculus I am still lost as to how to associate behaviour with data types and structures. I am guessing I am still in the wrong mindset.

Apart from the identity function, I would have thought that every other arithmetic operation depends on rules specific to the value types or structure.

For example, Matrices, Vectors, Scalar, Random Number Distribution and Imaginary numbers all have their own associative, commutative and and arithmetic rules.

How are types and or behaviours attached to values and/or operators?

As in any other programming language, that is developing suitable libraries. Consider for instance a very basic calculus, like the calculus of inductive constructors (CIC), that is no too far from a (typed) lambda calculus. CIC is the core of the Coq proof system: everything is written is this basic calculus, and still you may write complex programs on all the datatypes you mentioned (and reason about them). One crucial point that helps to understand lambda calculus is the so called Bohm-Berarducci encoding of inductive types ( automatic synthesis of type lambda programs on term algebras ), that provides the main techniques to work on integers, records, lists, trees, and so on. The rest is easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM