module Data.Name.Iso where

import Data.Name
import Control.Lens
import qualified Language.Haskell.TH as TH

nameIso :: Iso String String (Maybe Name) Name
nameIso = iso nameMay unName

-- | unsafe
-- >>> "hello" ^. nameIso'
-- hello
nameIso' :: Iso' String Name
nameIso' = iso toName unName

-- | there are lack of info a little
thNameIso :: Iso' Name TH.Name
thNameIso = iso (TH.mkName . unName) (toName . show)
