code-conjure-0.5.0: synthesize Haskell functions out of partial definitions
Copyright(c) 2021 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Conjure.Utils

Description

An internal module of Conjure. This exports List, Maybe, Function and a few other simple utitilites.

Synopsis

Documentation

module Data.List

module Data.Maybe

module Data.Tuple

count :: (a -> Bool) -> [a] -> Int Source #

Counts the number of occurrences on a list.

nubOn :: Eq b => (a -> b) -> [a] -> [a] Source #

Nubs using a given field.

nubSort :: Ord a => [a] -> [a] Source #

Equivalent to nub . sort but running in O(n log n).

mzip :: Monoid a => [a] -> [a] -> [a] Source #

Zips Monoid values leaving trailing values.

> mzip ["ab","cd"] ["ef"]
["abef","cd"]

groupOn :: Eq b => (a -> b) -> [a] -> [[a]] Source #

Group values using a given field selector.

idIO :: (a -> IO ()) -> a -> a Source #

WARNING: uses unsafePerformIO and should only be used for debugging!

> idIO print 10
10
10

mapHead :: (a -> a) -> [a] -> [a] Source #

Applies a function to the head of a list.

sets :: [a] -> [[a]] Source #

Return sets of values based on the list.

The values in the list must me unique.

headOr :: a -> [a] -> a Source #

Like head but allows providing a default value.

allEqual :: Eq a => [a] -> Bool Source #

Checks if all elements of a list are equal.

choices :: [a] -> [(a, [a])] Source #

Lists choices of values.

choicesThat :: (a -> [a] -> Bool) -> [a] -> [(a, [a])] Source #

Lists choices of values that follow a property.