module TPDB.Input.Memory
where
import TPDB.Data
import TPDB.Plain.Read
import TPDB.XTC.Read
import qualified Data.Text.Lazy as T
import System.FilePath.Posix ( takeExtension )
get :: String -> T.Text
-> IO (Either String (Either (TRS Identifier Identifier) (SRS Identifier)))
get f s = case takeExtension f of
".srs" -> do
case srs s of
Left err -> return $ Left err
Right t -> return $ Right $ Right t
".trs" -> do
case TPDB.Plain.Read.trs s of
Left err -> return $ Left err
Right t -> return $ Right $ Left t
_ -> do
case readProblemT s of
Right p -> return $ Right $ Left $ TPDB.Data.trs p