Package frege.prelude.Arrays

Compiled: Wed Dec 05 00:00:09 PST 2012 from source file: frege/prelude/Arrays.fr

Package Documentation

This package provides basic definitions for the Frege language.

The /Prelude/ packages are imported explicitely or implicetely during compilation of any other package. They define basic data structures, classes and functions.

This package is /implementation specific/ insofar as the compiler may assume that certain items are defined here in a certain way. Changes may thus lead to compiler crashes or java code that will be rejected by the java compiler.

Table of Content

Imports

Type Aliases

type Array e = Array e
type IntArr = IntArr
type StringArr = Frozen StringArray

Classes

class StringSplitter r

Known Instances

Regex

Member Functions

split :: StringSplitter r => r -> String -> Frozen StringArray
splitted :: StringSplitter r => r -> String -> [String]

StringSplitter.split a String and return the result in a list

Instances

instance Cloneable IntArray

Member Functions

clone :: IntArray α -> IntArray β
pure native clone

inherited from Cloneable.clone

freeze :: IntArray α -> ST α IntArr

inherited from Cloneable.freeze

our :: IntArray α -> ST α IntArr
native frege.RT.our
thaw :: IntArr -> Mutable IntArray α

inherited from Cloneable.thaw

withFrozen :: IntArray α -> (IntArr->β) -> ST α β

inherited from Freezable.withFrozen

instance Cloneable STArray elem

Member Functions

clone :: STArray β γ -> STArray β α
pure native clone

inherited from Cloneable.clone

freeze :: STArray α β -> ST β (Array α)

inherited from Cloneable.freeze

our :: STArray α β -> ST β (Array α)
native frege.RT.our
thaw :: Array α -> Mutable (STArray α) β

inherited from Cloneable.thaw

withFrozen :: STArray β α -> (Array β->γ) -> ST α γ

inherited from Freezable.withFrozen

instance Cloneable StringArray

Member Functions

clone :: StringArray α -> StringArray β
pure native clone

inherited from Cloneable.clone

freeze :: StringArray α -> ST α (Frozen StringArray)

inherited from Cloneable.freeze

our :: StringArray α -> ST α (Frozen StringArray)
native frege.RT.our
thaw :: Frozen StringArray -> Mutable StringArray α

inherited from Cloneable.thaw

withFrozen :: StringArray α -> (Frozen StringArray->β) -> ST α β

inherited from Freezable.withFrozen

instance StringSplitter Regex

Member Functions

split :: Regex -> String -> Frozen StringArray
pure native split
splitted :: Regex -> String -> [String]

inherited from StringSplitter.splitted

Data Types

data IntArray s = native int[]

native array of primitive int

Member Functions

elemAt :: IntArr -> Int -> Int
pure native frege.rt.Box.Int.arrayGet

get element at index from an immutable array

fromInxList :: [(Int, Int)] -> IntArr

Create an immutable int array from list of tuples.

The first component of each tuple gives the index, the second one is the value. Array elements not mentioned in the list will be 0.

 (IntArr.fromList [(7,42)]).toList == [0,0,0,0,0,0,0,42]
fromInxListST :: [(Int, Int)] -> Mutable IntArray α
fromList :: [Int] -> IntArr

create an immutable int array from a list

fromListST :: [Int] -> Mutable IntArray α

create a mutable int array from a list

frozenGetAt :: IntArr -> Int -> Int
pure native frege.rt.Box.Int.arrayGet

get element at index from an immutable array

getAt :: IntArray s -> Int -> ST s Int
native frege.rt.Box.Int.arrayGet

get element at index from a mutable array

length :: IntArr -> Int
pure native frege.rt.Box.Int.arrayLen

get the length of the array

new :: Int -> Mutable IntArray s
native frege.rt.Box.Int.arrayNew

make a new mutable array of given size

setAt :: IntArray s -> Int -> Int -> ST s ()
native frege.rt.Box.Int.arraySet

set element at index

toList :: IntArr -> [Int]

convert immutable array to list

data STArray elem s = native frege.rt.Array

Member Functions

elemAt :: STArray elem s -> Int -> ST s elem
native getAt

Fetch array element without checking for null value.

To be used only when it is sure that there are no null values in the array.

fromInxList :: [(Int, α)] -> Array α

create immutable array using frozen result of STArray.fromInxListST

fromInxListST :: [(Int, a)] -> Mutable (STArray a) s

Create a mutable array from a list of tuples (Int, a). The size of the array will be so that it can accomodate the greatest index. Elements whose index does not appear in the list reamin unset, i.e. they are initialised with the null value.

Negative indexes cause java exceptions to be thrown.

fromList :: [α] -> Array α

create an immutable arra from a list

fromListST :: [elem] -> Mutable (STArray elem) u

Create array from (finite) list.

The resulting Array does not contain null values

frozenElemAt :: Array elem -> Int -> elem
pure native getAt

Fetch array element from a frozen array without checking for null value.

frozenGetAt :: Array elem -> Int -> Maybe elem
pure native getAt

Fetch array element form a frozen array

getAt :: STArray elem s -> Int -> ST s (Maybe elem)
native getAt

Fetch array element and return Just v, if it is not a null value, otherwise Nothing

length :: STArray elem x -> Int
pure native length
new :: Int -> Mutable (STArray elem) s
native new
setAt :: STArray elem s -> Int -> elem -> ST s ()
native setAt
setAtMB :: STArray elem s -> Int -> Maybe elem -> ST s ()
native setAt

set array element to value v when passed (Just v) or null (Nothing)

toInxList :: Array a -> [(Int, a)]

Extract all non null elements from an immutable array, togehther with their indexes. For arrays whose last element is not null, the following holds:

 fromInxList (toInxList arr) == arr
toList :: Array α -> [α]

Collect non-null elements from an immutable array.

data StringArray s = native java.lang.String[]

native array of native strings

Member Functions

elemAt :: Frozen StringArray -> Int -> String
pure native frege.rt.Box.<java.lang.String>arrayGet

use this only if it is absolutely sure that there are no nulls in the array

fromList :: [String] -> Frozen StringArray
fromListST :: [String] -> ST u (Frozen StringArray)
frozenGetAt :: Frozen StringArray -> Int -> Maybe String
pure native frege.rt.Box.<java.lang.String>arrayGet
getAt :: StringArray s -> Int -> ST s (Maybe String)
native frege.rt.Box.<java.lang.String>arrayGet
length :: Frozen StringArray -> Int
pure native frege.rt.Box.<java.lang.String>arrayLen

the length of the array

new :: Int -> Mutable StringArray s
native java.lang.String[]

make a new mutable string array

setAt :: StringArray s -> Int -> String -> ST s ()
native frege.rt.Box.<java.lang.String>arraySet
toList :: Frozen StringArray -> [String]

Functions and Values by Type

IntArr -> Int -> Int

IntArray.elemAt, IntArray.frozenGetAt

IntArr -> [Int]

IntArray.toList

IntArr -> Int

IntArray.length

Frozen StringArray -> Int -> Maybe String

StringArray.frozenGetAt

Frozen StringArray -> Int -> String

StringArray.elemAt

Frozen StringArray -> [String]

StringArray.toList

Frozen StringArray -> Int

StringArray.length

[(Int, Int)] -> IntArr

IntArray.fromInxList

[String] -> Frozen StringArray

StringArray.fromList

[Int] -> IntArr

IntArray.fromList

Regex -> String -> Frozen StringArray

StringSplitter_Regex.split

Regex -> String -> [String]

StringSplitter_Regex.splitted

Array a -> [(Int, a)]

STArray.toInxList

Array elem -> Int -> Maybe elem

STArray.frozenGetAt

Array elem -> Int -> elem

STArray.frozenElemAt

Array α -> [α]

STArray.toList

IntArr -> Mutable IntArray α

Cloneable_IntArray.thaw

IntArray s -> Int -> Int -> ST s ()

IntArray.setAt

IntArray s -> Int -> ST s Int

IntArray.getAt

IntArray α -> ST α IntArr

Cloneable_IntArray.freeze, Cloneable_IntArray.our

Frozen StringArray -> Mutable StringArray α

Cloneable_StringArray.thaw

StringArray s -> Int -> String -> ST s ()

StringArray.setAt

StringArray s -> Int -> ST s (Maybe String)

StringArray.getAt

StringArray α -> ST α (Frozen StringArray)

Cloneable_StringArray.freeze, Cloneable_StringArray.our

[(Int, Int)] -> Mutable IntArray α

IntArray.fromInxListST

[(Int, α)] -> Array α

STArray.fromInxList

[String] -> ST u (Frozen StringArray)

StringArray.fromListST

[Int] -> Mutable IntArray α

IntArray.fromListST

[α] -> Array α

STArray.fromList

Int -> Mutable IntArray s

IntArray.new

Int -> Mutable StringArray s

StringArray.new

StringSplitter r => r -> String -> Frozen StringArray

StringSplitter.split

StringSplitter r => r -> String -> [String]

StringSplitter.splitted

STArray elem s -> Int -> Maybe elem -> ST s ()

STArray.setAtMB

STArray elem s -> Int -> elem -> ST s ()

STArray.setAt

STArray elem s -> Int -> ST s (Maybe elem)

STArray.getAt

STArray elem s -> Int -> ST s elem

STArray.elemAt

STArray elem x -> Int

STArray.length

Array α -> Mutable (STArray α) β

Cloneable_STArray.thaw

STArray α β -> ST β (Array α)

Cloneable_STArray.freeze, Cloneable_STArray.our

IntArray α -> (IntArr->β) -> ST α β

Cloneable_IntArray.withFrozen

IntArray α -> IntArray β

Cloneable_IntArray.clone

StringArray α -> (Frozen StringArray->β) -> ST α β

Cloneable_StringArray.withFrozen

StringArray α -> StringArray β

Cloneable_StringArray.clone

[(Int, a)] -> Mutable (STArray a) s

STArray.fromInxListST

[elem] -> Mutable (STArray elem) u

STArray.fromListST

Int -> Mutable (STArray elem) s

STArray.new

STArray β α -> (Array β->γ) -> ST α γ

Cloneable_STArray.withFrozen

STArray β γ -> STArray β α

Cloneable_STArray.clone

Valid HTML 4.01 Strict