hsc3-lang-0.15: Haskell SuperCollider Language

Safe HaskellSafe-Inferred
LanguageHaskell98

Sound.SC3.Lang.Core

Contents

Description

Core (shared) functions.

Synopsis

Data.Function variants

(.:) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) Source

fmap . fmap, ie. (t -> c) -> (a -> b -> t) -> a -> b -> c.

(.::) :: (Functor f, Functor g, Functor h) => (a -> b) -> f (g (h a)) -> f (g (h b)) Source

fmap . .:, ie. (t -> d) -> (a -> b -> c -> t) -> a -> b -> c -> d.

(.:::) :: (Functor f, Functor g, Functor h, Functor i) => (a -> b) -> f (g (h (i a))) -> f (g (h (i b))) Source

(.::::) :: (Functor f, Functor g, Functor h, Functor i, Functor j) => (a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b)))) Source

(.:::::) :: (Functor f, Functor g, Functor h, Functor i, Functor j, Functor k) => (a -> b) -> f (g (h (i (j (k a))))) -> f (g (h (i (j (k b))))) Source

Data.List variants

genericTakeMaybe :: Integral i => i -> [a] -> Maybe [a] Source

Variant that either takes precisely n elements or Nothing.

map (genericTake 3) (inits "abc") == inits "abc"
Data.Maybe.mapMaybe (genericTakeMaybe 3) (inits "abc") == ["abc"]

uncons :: [a] -> (Maybe a, [a]) Source

Inverse of :.

map uncons [[],1:[]] == [(Nothing,[]),(Just 1,[])]

lindex :: [a] -> Int -> Maybe a Source

Maybe variant of !!.

map (lindex "str") [2,3] == [Just 'r',Nothing]

take_inf :: Int -> [a] -> [a] Source

If n is maxBound this is id, else it is take.

transpose_fw :: Int -> [[a]] -> [[Maybe a]] Source

Variant of transpose for fixed width interior lists. Holes are represented by Nothing.

transpose_fw undefined [] == []
transpose [[1,3],[2,4]] == [[1,2],[3,4]]
transpose_fw 2 [[1,3],[2,4]] == [[Just 1,Just 2],[Just 3,Just 4]]
transpose [[1,5],[2],[3,7]] == [[1,2,3],[5,7]]
transpose_fw 2 [[1,4],[2],[3,6]] == [[Just 1,Just 2,Just 3]
                                    ,[Just 4,Nothing,Just 6]]

This function is more productive than transpose for the case of an infinite list of finite lists.

map head (transpose_fw 4 (repeat [1..4])) == map Just [1,2,3,4]
map head (transpose (repeat [1..4])) == _|_

transpose_fw_def :: a -> Int -> [[a]] -> [[a]] Source

Variant of transpose_fw with default value for holes.

transpose_fw_def' :: a -> [[a]] -> [[a]] Source

Variant of transpose_fw_def deriving width from first element.

transpose_st :: [[a]] -> [[a]] Source

A transpose variant, halting when first hole appears.

transpose_st [[1,2,3],[4,5,6],[7,8]] == [[1,4,7],[2,5,8]]

Data.Maybe variants

all_just :: [Maybe a] -> Maybe [a] Source

Variant of catMaybes that returns Nothing unless all elements are Just.

map all_just [[Nothing,Just 1],[Just 0,Just 1]] == [Nothing,Just [0,1]]

Data.Monoid variants

mcycle :: Monoid a => a -> a Source

mconcat of repeat, for lists this is cycle.

[1,2,3,1,2] `isPrefixOf` take 5 (mcycle [1,2,3])