Func.dcl 1.15 KB
Newer Older
1
definition module Data.Func
2

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * Function application.
 * @type (a -> b) a -> b
 */
Camil Staps's avatar
Camil Staps committed
7 8 9
($) infixr 0
($) f :== f

Camil Staps's avatar
Camil Staps committed
10 11 12 13
/**
 * Function application.
 * @type a -> a
 */
Camil Staps's avatar
Camil Staps committed
14 15
app f :== f

Camil Staps's avatar
Camil Staps committed
16 17 18 19 20 21 22 23 24
/**
 * Apply a state function to a list of values.
 * See also {{`mapSt`}}.
 *
 * @param The function.
 * @param The list of values.
 * @param The initial state.
 * @result The final state.
 */
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
25
seqSt        :: !(a .st -> .st)       ![a] !.st -> .st
Camil Staps's avatar
Camil Staps committed
26 27 28 29 30 31 32 33 34 35

/**
 * Apply a state function to a list of values and return the results.
 * See also {{`seqSt`}}.
 *
 * @param The function.
 * @param The list of values.
 * @param The initial state.
 * @result The value results and the final state.
 */
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
36
mapSt        :: !(a .st -> (!b,!.st)) ![a] !.st -> (![b],!.st)
Camil Staps's avatar
Camil Staps committed
37 38 39 40

/**
 * The fixed point combinator, reducing `fix f` to `f (fix f)`.
 */
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
41
fix          :: (a -> a) -> a
Camil Staps's avatar
Camil Staps committed
42 43 44 45 46 47

/**
 * Apply a binary function on another domain.
 *
 * Typical usage: `sortBy (on (<) toInt) :: [a] -> [a] | toInt a`
 */
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
48
on           :: (b b -> c) (a -> b) -> (a a -> c)
Mart Lubbers's avatar
Mart Lubbers committed
49

Camil Staps's avatar
Camil Staps committed
50 51 52
/**
 * Completely evaluate an expression (not just to head normal form like strictness).
 */
53
hyperstrict  :: !.a -> .a