1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Define a Visibilities type class

This commit is contained in:
Rick Winfrey 2018-12-19 19:10:49 -08:00
parent 2676e124be
commit 3adaf47a4f
2 changed files with 19 additions and 0 deletions

View File

@ -59,6 +59,7 @@ library
, Data.Abstract.Declarations , Data.Abstract.Declarations
, Data.Abstract.Evaluatable , Data.Abstract.Evaluatable
, Data.Abstract.FreeVariables , Data.Abstract.FreeVariables
, Data.Abstract.Visibilities.Visibilities
, Data.Abstract.Heap , Data.Abstract.Heap
, Data.Abstract.Live , Data.Abstract.Live
, Data.Abstract.Module , Data.Abstract.Module

View File

@ -0,0 +1,18 @@
module Data.Abstract.Visibilities.Visibilities
( Visibilities (..)
, Visibilities1 (..)
) where
import Data.Abstract.ScopeGraph (Visibility(..))
class Visibilities syntax where
termToVisibility :: syntax -> Maybe Visibility
termToVisibility = const Nothing
class Visibilities1 syntax where
-- | Lift a function mapping a Visibility syntax to its related Relation.
-- This can be used to find the Relation of a component syntax whose Visibility may be contained within a subterm.
--
-- Note that not all syntax will have contain Visibility syntax; in general its reserved for syntax where visibility is necessary for correctly resolving lookups of declarations (e.g. Method, PublicField, and other members whose containing syntax (i.e. Class, Module, etc.) can restrict visibility to external members).
liftTermToVisibility :: (a -> Maybe Visibility) -> syntax a -> Maybe Visibility
liftTermToVisibility _ _ = Nothing