mirror of
https://github.com/github/semantic.git
synced 2024-12-01 09:15:01 +03:00
Define a gensym operation, producing fresh names.
Co-Authored-By: Patrick Thomson <patrick.william.thomson@gmail.com>
This commit is contained in:
parent
5aed17c12b
commit
9a8756db08
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user