fcf-containers-0.1.0: Data structures and algorithms for first-class-families

Copyright(c) gspia 2020-
LicenseBSD
Maintainergspia
Safe HaskellSafe
LanguageHaskell2010

Fcf.Data.Set

Description

Fcf.Data.Set

Set provides an interface which is similar to the that given by the container-package. If a method is missing here that you need, please do open up an issue or better, make a PR.

Many of the examples are from containers-package. The internal representation is based on lists. We hope that a more efficient one will be used one day.

Synopsis

Documentation

>>> import qualified GHC.TypeLits as TL
>>> import           Fcf.Data.Nat

data Set a Source #

Set-definition.

Constructors

Set [a] 
Instances
type Eval (Empty :: Set v -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Empty :: Set v -> Type) = Set ([] :: [v])
type Eval (Singleton v :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Singleton v :: Set a -> Type) = Set (v ': ([] :: [a]))
type Eval (FromList lst :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (FromList lst :: Set a -> Type) = Set lst
type Eval (Insert v (Set lst) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Insert v (Set lst) :: Set a -> Type) = If (Eval (Elem v lst)) (Set lst) (Set (v ': lst))
type Eval (Delete v (Set lst) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Delete v (Set lst) :: Set a -> Type) = Set (Eval (Filter (Not <=< (TyEq v :: a -> Bool -> Type)) lst))
type Eval (Union (Set lst1) (Set lst2) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Union (Set lst1) (Set lst2) :: Set a -> Type) = Set (Eval (Foldr (UComb :: a -> [a] -> [a] -> Type) lst1 lst2))
type Eval (Difference (Set lst1) (Set lst2) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Difference (Set lst1) (Set lst2) :: Set a -> Type) = Set (Eval (Filter (DiffNotMem lst2) lst1))
type Eval (Intersection (Set lst1) (Set lst2) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Intersection (Set lst1) (Set lst2) :: Set a -> Type) = Set (Eval (Filter (InterMem lst2) lst1))

data Empty :: Exp (Set v) Source #

Empty

Example

>>> :kind! (Eval Empty :: Set Nat)
(Eval Empty :: Set Nat) :: Set Nat
= 'Set '[]

See also the other examples in this module.

Instances
type Eval (Empty :: Set v -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Empty :: Set v -> Type) = Set ([] :: [v])

data Singleton :: v -> Exp (Set v) Source #

Singleton

Example

>>> :kind! Eval (Singleton 1)
Eval (Singleton 1) :: Set Nat
= 'Set '[1]
Instances
type Eval (Singleton v :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Singleton v :: Set a -> Type) = Set (v ': ([] :: [a]))

data FromList :: [v] -> Exp (Set v) Source #

Use FromList to construct a Set from type-level list.

Example

>>> :kind! Eval (FromList '[1, 2])
Eval (FromList '[1, 2]) :: Set Nat
= 'Set '[1, 2]
Instances
type Eval (FromList lst :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (FromList lst :: Set a -> Type) = Set lst

data Insert :: v -> Set v -> Exp (Set v) Source #

Insert

Example

>>> :kind! Eval (Insert 3 =<< FromList '[1, 2])
Eval (Insert 3 =<< FromList '[1, 2]) :: Set Nat
= 'Set '[3, 1, 2]
>>> :kind! Eval (Insert 2 =<< FromList '[1, 2])
Eval (Insert 2 =<< FromList '[1, 2]) :: Set Nat
= 'Set '[1, 2]
Instances
type Eval (Insert v (Set lst) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Insert v (Set lst) :: Set a -> Type) = If (Eval (Elem v lst)) (Set lst) (Set (v ': lst))

data Delete :: v -> Set v -> Exp (Set v) Source #

Delete

Example

>>> :kind! Eval (Delete 5 =<< FromList '[5, 3])
Eval (Delete 5 =<< FromList '[5, 3]) :: Set Nat
= 'Set '[3]
>>> :kind! Eval (Delete 7 =<< FromList '[5, 3])
Eval (Delete 7 =<< FromList '[5, 3]) :: Set Nat
= 'Set '[5, 3]
Instances
type Eval (Delete v (Set lst) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Delete v (Set lst) :: Set a -> Type) = Set (Eval (Filter (Not <=< (TyEq v :: a -> Bool -> Type)) lst))

data Member :: v -> Set v -> Exp Bool Source #

Member

Example

>>> :kind! Eval (Member 5 =<< FromList '[5, 3])
Eval (Member 5 =<< FromList '[5, 3]) :: Bool
= 'True
>>> :kind! Eval (Member 7 =<< FromList '[5, 3])
Eval (Member 7 =<< FromList '[5, 3]) :: Bool
= 'False
Instances
type Eval (Member v (Set lst) :: Bool -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Member v (Set lst) :: Bool -> Type) = Eval (Elem v lst)

data NotMember :: v -> Set v -> Exp Bool Source #

NotMember

Example

>>> :kind! Eval (NotMember 5 =<< FromList '[5, 3])
Eval (NotMember 5 =<< FromList '[5, 3]) :: Bool
= 'False
>>> :kind! Eval (NotMember 7 =<< FromList '[5, 3])
Eval (NotMember 7 =<< FromList '[5, 3]) :: Bool
= 'True
Instances
type Eval (NotMember k (Set lst) :: Bool -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (NotMember k (Set lst) :: Bool -> Type) = Eval (Not =<< Elem k lst)

data Null :: Set v -> Exp Bool Source #

Null

Example

>>> :kind! Eval (Null =<< FromList '[5, 3])
Eval (Null =<< FromList '[5, 3]) :: Bool
= 'False
>>> :kind! Eval (Null =<< Empty)
Eval (Null =<< Empty) :: Bool
= 'True
Instances
type Eval (Null (Set (_1 ': _2)) :: Bool -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Null (Set (_1 ': _2)) :: Bool -> Type) = False
type Eval (Null (Set ([] :: [v])) :: Bool -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Null (Set ([] :: [v])) :: Bool -> Type) = True

data Size :: Set v -> Exp Nat Source #

Size

Example

>>> :kind! Eval (Size =<< FromList '[5, 3])
Eval (Size =<< FromList '[5, 3]) :: Nat
= 2
Instances
type Eval (Size (Set lst) :: Nat -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Size (Set lst) :: Nat -> Type) = Eval (Length lst)

data Union :: Set v -> Set v -> Exp (Set v) Source #

Union

Example

>>> :kind! Eval (Union (Eval (FromList '[5, 3])) (Eval (FromList '[5, 7])) )
Eval (Union (Eval (FromList '[5, 3])) (Eval (FromList '[5, 7])) ) :: Set 
                                                                       Nat
= 'Set '[7, 5, 3]
Instances
type Eval (Union (Set lst1) (Set lst2) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Union (Set lst1) (Set lst2) :: Set a -> Type) = Set (Eval (Foldr (UComb :: a -> [a] -> [a] -> Type) lst1 lst2))

data UComb :: v -> [v] -> Exp [v] Source #

Instances
type Eval (UComb v lst :: [a] -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (UComb v lst :: [a] -> Type) = If (Eval (Elem v lst)) lst (v ': lst)

data Difference :: Set v -> Set v -> Exp (Set v) Source #

Difference

Example

>>> :kind! Eval (Difference (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7])))
Eval (Difference (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7]))) :: Set 
                                                                           Nat
= 'Set '[3]
Instances
type Eval (Difference (Set lst1) (Set lst2) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Difference (Set lst1) (Set lst2) :: Set a -> Type) = Set (Eval (Filter (DiffNotMem lst2) lst1))

data DiffNotMem :: [v] -> v -> Exp Bool Source #

Instances
type Eval (DiffNotMem lst v :: Bool -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (DiffNotMem lst v :: Bool -> Type) = Eval (Not =<< Elem v lst)

data Intersection :: Set v -> Set v -> Exp (Set v) Source #

Intersection

Example

>>> :kind! Eval (Intersection (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7])))
Eval (Intersection (Eval (FromList '[3, 5])) (Eval (FromList '[5, 7]))) :: Set 
                                                                             Nat
= 'Set '[5]
Instances
type Eval (Intersection (Set lst1) (Set lst2) :: Set a -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (Intersection (Set lst1) (Set lst2) :: Set a -> Type) = Set (Eval (Filter (InterMem lst2) lst1))

data InterMem :: [v] -> v -> Exp Bool Source #

Instances
type Eval (InterMem lst v :: Bool -> Type) Source # 
Instance details

Defined in Fcf.Data.Set

type Eval (InterMem lst v :: Bool -> Type) = Eval (Elem v lst)