ZV7PIRTUNQYLWJQWKG73RC2X7MKSUMPGU7HQUW7TIBXB4OSYYDBAC
{-# LANGUAGE TemplateHaskell #-}
module Location
( -- * Classes
Location (..)
) where
import Data.PrintableText
import Control.Lens
import Control.Lens.TH
-- |Location of map in FFX in the form 'Area - Section'
data Location
= Location
{ _area :: PrintableText
, _section :: PrintableText
}
$(makeLenses ''Location)
module Data.PrintableText
( -- * Classes
PrintableText
-- * Constructors
, singleton
, fromText
-- * Destructure
, unPrintableText
) where
import Data.Char (isPrint)
import qualified Data.Text as T
-- |A non empty string that has atleast one printable character
newtype PrintableText = PrintableText { unPrintableText :: T.Text }
deriving (Eq, Ord, Show)
-- |Create a PrintableText from a single Char
singleton :: Char -> PrintableText
singleton = PrintableText . T.singleton
-- |Attempt to create a PrintableText from a Text, returns Nothing if no printable characters detected
fromText :: T.Text -> Maybe PrintableText
fromText x
| T.all isPrint x = Just $ PrintableText x
| otherwise = Nothing