module Drasil.Database.TypedUIDRef
  ( TypedUIDRef(..), -- FIXME: do not export the constructor
    mkRef
  )
where

import Drasil.Database.Chunk (IsChunk)
import Drasil.Database.UID (HasUID (uid), UID)
import Control.Lens ((^.))

-- | 'UID' references that contain information about the type of data the 'UID'
-- refers to, useful for type-safe dereferencing.
newtype TypedUIDRef typ = TypedUIDRef UID

-- | Create a 'TypedUIDRef' to a chunk.
mkRef :: IsChunk t => t -> TypedUIDRef t
mkRef :: forall t. IsChunk t => t -> TypedUIDRef t
mkRef t
t = UID -> TypedUIDRef t
forall typ. UID -> TypedUIDRef typ
TypedUIDRef (UID -> TypedUIDRef t) -> UID -> TypedUIDRef t
forall a b. (a -> b) -> a -> b
$ t
t t -> Getting UID t UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID t UID
forall c. HasUID c => Getter c UID
Getter t UID
uid