Copyright | (c) gspia 2020- |
---|---|
License | BSD |
Maintainer | gspia |
Safe Haskell | Safe |
Language | Haskell2010 |
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
- data Set a = Set [a]
- data Empty :: Exp (Set v)
- data Singleton :: v -> Exp (Set v)
- data FromList :: [v] -> Exp (Set v)
- data Insert :: v -> Set v -> Exp (Set v)
- data Delete :: v -> Set v -> Exp (Set v)
- data Member :: v -> Set v -> Exp Bool
- data NotMember :: v -> Set v -> Exp Bool
- data Null :: Set v -> Exp Bool
- data Size :: Set v -> Exp Nat
- data Union :: Set v -> Set v -> Exp (Set v)
- data UComb :: v -> [v] -> Exp [v]
- data Difference :: Set v -> Set v -> Exp (Set v)
- data DiffNotMem :: [v] -> v -> Exp Bool
- data Intersection :: Set v -> Set v -> Exp (Set v)
- data InterMem :: [v] -> v -> Exp Bool
Documentation
>>>
import qualified GHC.TypeLits as TL
>>>
import Fcf.Data.Nat
Set-definition.
Set [a] |
Instances
type Eval (Empty :: Set v -> Type) Source # | |
type Eval (Singleton v :: Set a -> Type) Source # | |
type Eval (FromList lst :: Set a -> Type) Source # | |
type Eval (Insert v (Set lst) :: Set a -> Type) Source # | |
type Eval (Delete v (Set lst) :: Set a -> Type) Source # | |
type Eval (Union (Set lst1) (Set lst2) :: Set a -> Type) Source # | |
type Eval (Difference (Set lst1) (Set lst2) :: Set a -> Type) Source # | |
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 # | |
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.
data Singleton :: v -> Exp (Set v) Source #
Singleton
Example
>>>
:kind! Eval (Singleton 1)
Eval (Singleton 1) :: Set Nat = 'Set '[1]
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]
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]
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]
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
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
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
data Size :: Set v -> Exp Nat Source #
Size
Example
>>>
:kind! Eval (Size =<< FromList '[5, 3])
Eval (Size =<< FromList '[5, 3]) :: Nat = 2
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]
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 # | |
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 # | |
Defined in Fcf.Data.Set |