express-1.0.16: Dynamically-typed expressions involving function application and variables.
Copyright(c) 2019-2024 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Express.Triexpr

Description

This module is part of Express.

An experimental data structure for matching Exprs.

Warning (1): Take care when importing this module, the interface is experimental and may change at every minor version.

Warning (2): YMMV: Do not expect this to be faster than manually matching in a list, provisional experiments show that it can be slower depending on the set of expressions being matched.

This module should be imported qualified as it exports definitions called map, lookup, toList, fromList, insert and empty:

import Data.Express.Triexpr (Triexpr)
import qualified Data.Express.Triexpr as T
Synopsis

Documentation

newtype Triexpr a Source #

A trie of Exprs.

In the representation, Nothing matches an App and Just Expr an expression.

Constructors

Triexpr [(Maybe Expr, Either (Triexpr a) (Expr, a))] 

Instances

Instances details
Show a => Show (Triexpr a) Source # 
Instance details

Defined in Data.Express.Triexpr

Methods

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

show :: Triexpr a -> String #

showList :: [Triexpr a] -> ShowS #

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

Defined in Data.Express.Triexpr

Methods

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

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

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

Defined in Data.Express.Triexpr

Methods

compare :: Triexpr a -> Triexpr a -> Ordering #

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

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

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

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

max :: Triexpr a -> Triexpr a -> Triexpr a #

min :: Triexpr a -> Triexpr a -> Triexpr a #

empty :: Triexpr a Source #

An empty Triexpr.

unit :: Expr -> a -> Triexpr a Source #

Constructs a Triexpr encoding a single expression.

merge :: Triexpr a -> Triexpr a -> Triexpr a Source #

Merges two Triexprs.

insert :: Expr -> a -> Triexpr a -> Triexpr a Source #

Inserts an Expr into a Triexpr.

toList :: Triexpr a -> [(Expr, a)] Source #

List all Expr stored in a Triexpr along with their associated values.

fromList :: [(Expr, a)] -> Triexpr a Source #

Constructs a Triexpr form a list of key Exprs and associated values.

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

Maps a function to the stored values in a Triexpr.

lookup :: Expr -> Triexpr a -> [(Expr, [(Expr, Expr)], a)] Source #

Performs a lookup in a Triexpr.