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

Define a gensym operation, producing fresh names.

Co-Authored-By: Patrick Thomson <patrick.william.thomson@gmail.com>
This commit is contained in:
Rob Rix 2018-07-09 13:31:15 -04:00
parent 5aed17c12b
commit 9a8756db08

View File

@ -2,11 +2,14 @@
module Data.Abstract.Name
( Name
-- * Constructors
, gensym
, name
, nameI
, formatName
) where
import Control.Monad.Effect
import Control.Monad.Effect.Fresh
import Data.Aeson
import qualified Data.Char as Char
import Data.Text (Text)
@ -33,6 +36,9 @@ instance Primitive Name where
decodePrimitive = Name . LT.toStrict <$> Decode.text <|> I <$> Decode.int
primType _ = Bytes
gensym :: (Functor (m effs), Member Fresh effs, Effectful m) => m effs Name
gensym = I <$> fresh
-- | Construct a 'Name' from a 'Text'.
name :: Text -> Name
name = Name