[Haskell-cafe] Are there arithmetic composition of functions?

oleg at okmij.org oleg at okmij.org
Thu Mar 22 07:27:41 CET 2012

> At present we can easily express different flavors of conjunction, but
> expressing disjunction is hard. 

Disjunction is not particularly difficult. See, for example,


and search for ORELSE. The code demonstrates higher-order type-level
programming (for example, higher-order function Member with
the equality predicate as the argument). The file implements
closed-world negation for type predicates. See
for explanations.

Incidentally, one application of that machinery is precisely your
original problem. The code

implements vector spaces as function spaces, so you can use the same
operation <+> :: Vspace v => v -> v -> v to add arguments of the type
(Num n =>n), Num n => a -> n, Num n => a -> b -> n, etc.
(there is also a scalar-vector multiplication).

More information about the Haskell-Cafe mailing list