tungsten-0.1.0.0: Bring fusion to everyone

Copyright(c) Alexandre Moine 2019
Maintaineralexandre@moine.me
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Tungsten.Structure.List

Contents

Description

This module defines a type isomorphic to linked lists, in terms of Fix from Tungsten.Fix.

A good consumer is a function that can be fused with a good producer. A good producer is a function that can be fused with a good consumer.

Synopsis

Lists as fixed-points

data ListF a b Source #

The factored-out recursive type for lists.

Constructors

NilF 
ConsF a b 
Instances
Eq2 ListF Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> ListF a c -> ListF b d -> Bool #

Ord2 ListF Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> ListF a c -> ListF b d -> Ordering #

Show2 ListF Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> ListF a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [ListF a b] -> ShowS #

Functor (ListF a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

fmap :: (a0 -> b) -> ListF a a0 -> ListF a b #

(<$) :: a0 -> ListF a b -> ListF a a0 #

Eq a => Eq1 (ListF a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

liftEq :: (a0 -> b -> Bool) -> ListF a a0 -> ListF a b -> Bool #

Ord a => Ord1 (ListF a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

liftCompare :: (a0 -> b -> Ordering) -> ListF a a0 -> ListF a b -> Ordering #

Show a => Show1 (ListF a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> ListF a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [ListF a a0] -> ShowS #

(Eq a, Eq b) => Eq (ListF a b) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

(==) :: ListF a b -> ListF a b -> Bool #

(/=) :: ListF a b -> ListF a b -> Bool #

(Ord a, Ord b) => Ord (ListF a b) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

compare :: ListF a b -> ListF a b -> Ordering #

(<) :: ListF a b -> ListF a b -> Bool #

(<=) :: ListF a b -> ListF a b -> Bool #

(>) :: ListF a b -> ListF a b -> Bool #

(>=) :: ListF a b -> ListF a b -> Bool #

max :: ListF a b -> ListF a b -> ListF a b #

min :: ListF a b -> ListF a b -> ListF a b #

(Read a, Read b) => Read (ListF a b) Source # 
Instance details

Defined in Tungsten.Structure.List

(Show a, Show b) => Show (ListF a b) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

showsPrec :: Int -> ListF a b -> ShowS #

show :: ListF a b -> String #

showList :: [ListF a b] -> ShowS #

newtype List a Source #

Linked lists as a fixed-point.

Constructors

List (Fix (ListF a)) 
Instances
Monad List Source #

>>= is a good consumer and producer.

Instance details

Defined in Tungsten.Structure.List

Methods

(>>=) :: List a -> (a -> List b) -> List b #

(>>) :: List a -> List b -> List b #

return :: a -> List a #

fail :: String -> List a #

Functor List Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

fmap :: (a -> b) -> List a -> List b #

(<$) :: a -> List b -> List a #

Applicative List Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

pure :: a -> List a #

(<*>) :: List (a -> b) -> List a -> List b #

liftA2 :: (a -> b -> c) -> List a -> List b -> List c #

(*>) :: List a -> List b -> List b #

(<*) :: List a -> List b -> List a #

IsList (List a) Source # 
Instance details

Defined in Tungsten.Structure.List

Associated Types

type Item (List a) :: Type #

Methods

fromList :: [Item (List a)] -> List a #

fromListN :: Int -> [Item (List a)] -> List a #

toList :: List a -> [Item (List a)] #

Eq a => Eq (List a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

(==) :: List a -> List a -> Bool #

(/=) :: List a -> List a -> Bool #

Ord a => Ord (List a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

compare :: List a -> List a -> Ordering #

(<) :: List a -> List a -> Bool #

(<=) :: List a -> List a -> Bool #

(>) :: List a -> List a -> Bool #

(>=) :: List a -> List a -> Bool #

max :: List a -> List a -> List a #

min :: List a -> List a -> List a #

Show a => Show (List a) Source # 
Instance details

Defined in Tungsten.Structure.List

Methods

showsPrec :: Int -> List a -> ShowS #

show :: List a -> String #

showList :: [List a] -> ShowS #

type Item (List a) Source # 
Instance details

Defined in Tungsten.Structure.List

type Item (List a) = a

nil :: List a Source #

The empty list. Similar to 'Prelude.[]' for Prelude lists.

cons :: a -> List a -> List a Source #

The cons operator. Similar to 'Prelude.(:)' for Prelude lists.

Classical operations on lists

foldr :: (a -> b -> b) -> b -> List a -> b Source #

The classical right fold. Good consumer.

map :: (a -> b) -> List a -> List b Source #

The classical map. Good consumer and good producer.

append :: List a -> List a -> List a Source #

Append two lists. Good consumers of both arguments and producer.

Operations on lists

elem :: Eq a => a -> List a -> Bool Source #

Search an element in a list. Good consumer.

range :: Int -> Int -> List Int Source #

range start end will produce a list containing int in ascending order from start (inclusive) to end (exclusive). Good producer.

Conversions

toList :: List a -> [a] Source #

Transform a fixed-point list into a Prelude one. Good producer (of Prelude lists) and good consumer (of fixed-point lists).

fromList :: [a] -> List a Source #

Transform a Prelude list into a fixed-point one. Good producer (fixed-point lists) and good consumer of (of Prelude lists).