fix is:module -package:indexed -package:gi-gtk

Monadic fixpoints. For a detailed discussion, see Levent Erkok's thesis, Value Recursion in Monadic Computations, Oregon Graduate Institute, 2002.
Fixed points of a functor. Type f should be a Functor if you want to use simple recursion schemes or Traversable if you want to use monadic recursion schemes. This style allows you to express recursive functions in non-recursive manner. You can imagine that a non-recursive function holds values of the previous iteration. An example: First we define a base functor. The arguments b are recursion points.
>>> data ListF a b = Nil | Cons a b deriving (Show, Functor)
The list is then a fixed point of ListF
>>> type List a = Fix (ListF a)
We can write length function. Note that the function we give to foldFix is not recursive. Instead the results of recursive calls are in b positions, and we need to deal only with one layer of the structure.
>>> :{
let length :: List a -> Int
length = foldFix $ \x -> case x of
Nil      -> 0
Cons _ n -> n + 1
:}
If you already have recursive type, like '[Int]', you can first convert it to `Fix (ListF a)` and then foldFix. Alternatively you can use recursion-schemes combinators which work directly on recursive types.
Monad transformer for evaluating to a fixpoint. The idea is that some transforms need to be run multiple times. Deciding whether to run a transform again can be somewhat tedious though, as you cannot necessarily just run some transform f on x until f x == x. This might not be ideal for a few reasons:
  • x might not implement Eq;
  • x might implement Eq, but could contain floats of NaN, in which case NaN /= NaN; or
  • checking equality can be expensive.
Instead, this provides a function called progress, with the same type as return, that marks the current transform as having "made progress": that is, it should be re-run again. Then you can call fixpoint with a function of type a -> FixT m a, which will be re-run until no progress is made.
This module defines a "Fixed" type for fixed-precision arithmetic. The parameter to Fixed is any type that's an instance of HasResolution. HasResolution has a single method that gives the resolution of the Fixed type. This module also contains generalisations of div, mod, and divMod to work with any Real instance.
Fixity
Fixity information to give the parser so that infix operators can be parsed properly.
A container which allows you to position widgets at fixed coordinates
Various fixups in the introspection data.
Provides TextShow instance for Fixed, as well as the showbFixed function. Since: 2
Fixed point numbers. They are implemented as ratios with fixed denominator. Many routines fail for some arguments. When they work, they can be useful for obtaining approximations of some constants. We have not paid attention to rounding errors and thus some of the trailing digits may be wrong.
Collecting fixity declarations (and polarity pragmas) for concrete declarations.
Definitions for fixity, precedence levels, and declared syntax.
Defines types for manipulation of quantities with fixed point representations.
Generic API for vectors with fixed length. For encoding of vector size library uses Peano naturals defined in the library. At come point in the future it would make sense to switch to new GHC type level numerals.
  • Common pitfalls
Library provide instances for tuples. But there's a catch. Tuples are monomorphic in element type. Let consider 2-tuple (Int,Int). Vector type v is (,) Int and only allowed element type is Int. Because of that we cannot change element type and following code will fail:
>>> map (== 1) ((1,2) :: (Int,Int))

<interactive>:3:1:
Couldn't match type `Int' with `Bool'
In the expression: F.map (== 1) ((1, 2) :: (Int, Int))
In an equation for `it': it = map (== 1) ((1, 2) :: (Int, Int))
To make it work we need to change vector type as well. Functions from module Data.Vector.Fixed.Generic provide this functionality.
>>> map (== 1) ((1,2) :: (Int,Int)) :: (Bool,Bool)
(True,False)