Does OCaml Have Merger Laws

I recently read some books on functional programming with Haskell.

Haskell seems to be quite comfortable with “modular programs,” for example,

f :: (Integer,Integer) -> Integer
f = sum . map sq . filter . odd . between

although the same function can be written as

f' (m, n) = go m
  where go m | m > n = 0
             | otherwise = go (m + 1) + if odd m then sq m else 0

Merger laws are also quite popular and used ( http://www.cs.ox.ac.uk/ralf.hinze/publications/IFL10.pdf )


I am not an OCaml expert, but I would use fold_leftor fold_right, if possible, and be simple and effective (for example, in any case, I need to scan the entire list and not stop in the middle).

However, in most cases I will write explicit recursive code using "pattern matching".

OCaml github, .

, OCaml.


  • OCaml , , Haskell?
  • OCaml ?
  • OCaml, - Haskell?
+4
2

Fusion OCaml, Haskell - . OCaml , GHC, , , , . , , OCaml " ", . , OCaml, .

loop-fusion, Haskell. OCaml -, .

Fusion - Haskell. , , .

, , OCaml.

+7

, fusion OCaml (): , , , - , .

, , Haskell (GHC) ( ), + . OCaml , , OCaml. , InfoQ:

, , , OCaml, . OCaml, Haskell.

:

  • . OCaml stdlib , , .
  • . , camlp4 -libs.
  • OCaml , , , , OCaml-.
+3

All Articles