neural-0.3.0.0: Neural Networks in native Haskell

Copyright(c) Lars Brünjes, 2016
LicenseMIT
Maintainerbrunjlar@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010
Extensions
  • ScopedTypeVariables
  • GeneralizedNewtypeDeriving
  • ExplicitForAll

Data.Utils.List

Description

This module provides various utilities for working with lists.

Synopsis

Documentation

splitLast :: [a] -> Maybe ([a], a) Source #

Splits off the last element of a non-empty list.

>>> splitLast [1, 2, 3]
Just ([1,2],3)
>>> splitLast []
Nothing

pick :: Int -> [a] -> (a, [a]) Source #

Given a valid index, returns the list element at the index and the remaining elements.

>>> pick 1 [1,2,3,4]
(2,[1,3,4])

distribute :: Int -> [a] -> [[a]] Source #

Distributes the elements of a list as uniformly as possible amongst a specified number of groups.

>>> distribute 3 [1,2,3,4,5]
[[3],[4,1],[5,2]]

pad :: Int -> a -> [a] -> [a] Source #

Pads a litst with a provided element on the left.

>>> pad 4 'x' "oo"
"xxoo"

data ListEditorT a m b Source #

ListEditorT a m is a monad transformer for editting lists of type [a].

Instances

Monad m => Monad (ListEditorT a m) Source # 

Methods

(>>=) :: ListEditorT a m a -> (a -> ListEditorT a m b) -> ListEditorT a m b #

(>>) :: ListEditorT a m a -> ListEditorT a m b -> ListEditorT a m b #

return :: a -> ListEditorT a m a #

fail :: String -> ListEditorT a m a #

Functor m => Functor (ListEditorT a m) Source # 

Methods

fmap :: (a -> b) -> ListEditorT a m a -> ListEditorT a m b #

(<$) :: a -> ListEditorT a m b -> ListEditorT a m a #

Monad m => Applicative (ListEditorT a m) Source # 

Methods

pure :: a -> ListEditorT a m a #

(<*>) :: ListEditorT a m (a -> b) -> ListEditorT a m a -> ListEditorT a m b #

(*>) :: ListEditorT a m a -> ListEditorT a m b -> ListEditorT a m b #

(<*) :: ListEditorT a m a -> ListEditorT a m b -> ListEditorT a m a #

editListT :: Monad m => ListEditorT a m () -> [a] -> m [a] Source #

Runs the editor.

editT :: Monad m => [a] -> ListEditorT a m () Source #

Replaces the list at the "cursor" with the provided list.

tryLeftT :: Monad m => ListEditorT a m Bool Source #

Tries to move the "cursor" to the left.

tryRightT :: Monad m => ListEditorT a m Bool Source #

Tries to move the "cursor" to the right.

focusT :: Monad m => ListEditorT a m [a] Source #

Gets the list under the "cursor".

type ListEditor a = ListEditorT a Identity Source #

Monad for pure list editting.

editList :: ListEditor a () -> [a] -> [a] Source #

Runs the pure editor.

>>> editList (do _ <- tryRightT; editT [3,2]) [1,2,3]
[1,3,2]

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

Gets all pairs of adjacent list elements.

>>> pairs "Haskell"
[('H','a'),('a','s'),('s','k'),('k','e'),('e','l'),('l','l')]

indexOf :: Eq a => [a] -> a -> Maybe Int Source #

Gets the first index of the provided element in the list or Nothing if it is not in the list.

>>> indexOf "Haskell" 'l'
Just 5
>>> indexOf "Haskell" 'y'
Nothing

safeHead :: [a] -> Maybe a Source #

Returns the head of a non-empty list or Nothing for the empty list.

>>> safeHead "Haskell"
Just 'H'
>>> safeHead ""
Nothing