Copyright | (c) gspia 2020- |
---|---|

License | BSD |

Maintainer | gspia |

Safe Haskell | Safe |

Language | Haskell2010 |

# Fcf.Alg.Sort

## Synopsis

- data ListCmpFnd :: [Ordering] -> Exp Ordering
- data ListCmp :: (a -> a -> Exp Ordering) -> [a] -> [a] -> Exp Ordering
- data ListOrd :: (a -> a -> Exp Ordering) -> [a] -> [a] -> Exp Bool
- data NatOrd :: Nat -> Nat -> Exp Ordering
- data SymbolListOrd :: [Symbol] -> [Symbol] -> Exp Bool
- data NatListOrd :: [Nat] -> [Nat] -> Exp Bool
- data PartHlp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a]
- data Inord :: Algebra (BTreeF a) [a]
- data Qsort :: (a -> a -> Exp Bool) -> [a] -> Exp [a]
- data PartCmp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a]

# Documentation

`>>>`

`import qualified Fcf.Data.Nat as N ( type (<) )`

`>>>`

`import qualified Fcf.Data.Symbol as S ( type (<) )`

data ListCmpFnd :: [Ordering] -> Exp Ordering Source #

## Instances

type Eval (ListCmpFnd (a ': as) :: Ordering -> Type) Source # | |

Defined in Fcf.Alg.Sort | |

type Eval (ListCmpFnd ([] :: [Ordering])) Source # | |

Defined in Fcf.Alg.Sort |

data ListCmp :: (a -> a -> Exp Ordering) -> [a] -> [a] -> Exp Ordering Source #

Compare lists with the given comparison for the elements.

data ListOrd :: (a -> a -> Exp Ordering) -> [a] -> [a] -> Exp Bool Source #

Give true if the first list is before the second, given the comparison function for the elements.

data NatOrd :: Nat -> Nat -> Exp Ordering Source #

Comparison for the Nats.

TODO: Would this fit to Fcf.Data.Nat on first-class-families?

data SymbolListOrd :: [Symbol] -> [Symbol] -> Exp Bool Source #

Comparison for Symbol lists.

Useful when sorting with Qsort.

## Instances

type Eval (SymbolListOrd as bs :: Bool -> Type) Source # | |

Defined in Fcf.Alg.Sort |

data NatListOrd :: [Nat] -> [Nat] -> Exp Bool Source #

Comparison for Nat lists.

Useful when sorting with Qsort.

## Instances

type Eval (NatListOrd as bs :: Bool -> Type) Source # | |

Defined in Fcf.Alg.Sort |

data PartHlp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a] Source #

data Qsort :: (a -> a -> Exp Bool) -> [a] -> Exp [a] Source #

Qsort - give the comparison function `a -> a -> Exp Bool`

comparing your
list elements and then Qsort will order the list.

**Example**

`>>>`

Eval (Qsort (N.<) '[5,3,1,9,4,6,3]) :: [Nat] = '[1, 3, 3, 4, 5, 6, 9]`:kind! Eval (Qsort (N.<) '[5,3,1,9,4,6,3])`

`>>>`

Eval (Qsort (S.<) '[ "bb", "e", "a", "e", "d" ]) :: [Symbol] = '["a", "bb", "d", "e", "e"]`:kind! Eval (Qsort (S.<) '[ "bb", "e", "a", "e", "d" ])`