dep-software-0.1.0.0
Maintainerhapytexeu+gh@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Dep.Utils

Description

This module defines utility functions that are used elsewhere in the software package.

Synopsis

List processing

toList' Source #

Arguments

:: Foldable f 
=> f a

The Foldable of elements that will yield items to the list.

-> [a]

The list of items that will follow after the items of the Foldable.

-> [a]

A list of items from the Foldable followed by the items of the tail.

Convert the given Foldable object to a list where one can specify a tail list.

zipWithLast Source #

Arguments

:: (a -> a -> a)

The given merge function.

-> [a]

The first given list of items.

-> [a]

The second given list of items.

-> [a]

The result of zipping the two lists until one of the lists is exhausted and then return the remaining items of the other list.

Perform a zipWith, but when one of the lists is exhausted the remaining elements of the other list are returned.

Lifting objects

applyExp Source #

Arguments

:: Foldable f 
=> Name

The name of the function to call.

-> f (Q Exp)

The Foldable of parameters that will be used in the function call.

-> Q Exp

An expression where a function with the given name is applied to the given Foldable of the parameter.

A function that create an expression by calling the function with the given name and a Foldable of parameters that are applied.

applyExp' Source #

Arguments

:: (Lift a, Foldable f) 
=> Name

The name of the function to call.

-> f a

The Foldable of items that will be lifted, and used in the function call.

-> Q Exp

An expression where a function with the given name is applied to the given Foldable of the parameter.

A function that create an expression by calling the function with the given name and a Foldable of items that are an instance of Lift. The lifted version of these items will be used to construct the expression.

Maybe utils

unionMaybeWith Source #

Arguments

:: (a -> a -> a)

The function to merge two Just objects.

-> Maybe a

The first given Maybe

-> Maybe a

The second given Maybe

-> Maybe a

The result of merging two Just objects, or the Just object if there is only one given.

Using the merge function if the two given Maybes use the Just data constructor. If one of the two is Nothing, then the item with the Just compiler is used. If the two are both Nothing, Nothing is returned.

Upperbound of a division

udiv Source #

Arguments

:: Integral i 
=> i

The given numerator.

-> i

The given denominator.

-> i

The corresponding division rounded up.

Divide the numerator by the denominator and round up.

Raster functions

type Raster a = [[a]] Source #

A Raster is a list of lists of items. This is for example used to render an image with Bricks where there are multiple layers.

toRaster Source #

Arguments

:: a

The given label or attribute that will be attached to the Raster.

-> Raster b

The given Raster of values that will be annotated.

-> Raster (a, b)

A Raster of 2-tuples where we annotate each item with the given label or attribute value.

Convert the given Rasters to a Raster of 2-tuples where the first item is a given "label" or "attribute".

flatRaster Source #

Arguments

:: (b -> Bool)

The predicate that returns True if we want to retain the item from the upper layer, and False if we want to retain the item from the lower layer.

-> [(a, Raster b)]

A list of annotated Rasters that will be merged to a signle Raster.

-> Raster (a, b)

A single Raster where each item is annotated with the label or attribute.

Convert a list of labeled Rasters to a single Raster where the predicate determines from which value we take the item.

flatRaster' Source #

Arguments

:: (a -> Bool)

The given predicate that returns True if we want to retain the upper Raster, and False if we want to retain the lower Raster.

-> [Raster a]

The list of Rasters that is ordered top-to-bottom.

-> Raster a

The resulting Raster where we perfor the merge between all the Rasters.

Convert the given Rasters to a raster where the given predicate decides if we retain the upper or lower layer.

Type aliasses

type Operator a = (a, a) -> a Source #

An alias for an operator: a function that takes two items of the same type, and produces an item. In case the function is associative, this can be used for a Semigroup.