1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Define a helper to derive printable names from Builtins.

This commit is contained in:
Rob Rix 2018-05-28 10:08:36 -04:00
parent d7cc70ec06
commit 46d871a98a

View File

@ -9,6 +9,7 @@ import Control.Abstract.Value
import Data.Abstract.Environment
import Data.Abstract.Name
import Data.ByteString.Char8 (pack, unpack)
import Data.Char
import Data.Semigroup.Reducer hiding (unit)
import Data.Semilattice.Lower
import Prologue
@ -16,6 +17,12 @@ import Prologue
data Builtin = Print
deriving (Eq, Ord, Show)
builtinName :: Builtin -> Name
builtinName = name . pack . ("__semantic_" <>) . headToLower . show
where headToLower (c:cs) = toLower c : cs
headToLower "" = ""
builtin :: ( HasCallStack
, Members '[ Allocator location value
, Reader (Environment location)