hashcons-0.1.0: Hash-consing and memoisation

Copyright© 2018 Andy Morris
LicenseBSD-3-Clause
Maintainerhello@andy-morris.xyz
Stabilityexperimental
PortabilityGHC internals
Safe HaskellNone
LanguageHaskell2010

Data.HashCons.ConstRef

Description

Read-only references with pointer equality.

Synopsis

Documentation

data ConstRef a Source #

A read-only reference.

A ConstRef is similar to an IORef in that it has its own identity.

do a <- newConstRef ()
   b <- newConstRef ()
   return $ a == b
     -- False

However, unlike most types of reference, it is immutable and its value is set at construction time. This is the reason why readConstRef does not need to return an IO value.

Instances

Eq (ConstRef a) Source #

Pointer equality

Methods

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

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

MkWeak (ConstRef a) Source # 

newConstRef :: a -> IO (ConstRef a) Source #

Make a new ConstRef.

readConstRef :: ConstRef a -> a Source #

Read the value of a ConstRef.