{-# LANGUAGE FlexibleContexts #-}

module Saturn.Unstable.Parse where

import qualified Data.Text as Text
import qualified Data.Text.Lazy as LazyText
import qualified Saturn.Unstable.Type.Schedule as Schedule
import qualified Text.Parsec as Parsec

-- | Parses a lazy 'LazyText.Text' value into a 'Schedule.Schedule'. See
-- 'fromText' for details.
fromLazyText :: LazyText.Text -> Either Parsec.ParseError Schedule.Schedule
fromLazyText :: Text -> Either ParseError Schedule
fromLazyText = forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
Parsec.parse forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Schedule
parsec String
""

-- | Parses a 'String' into a 'Schedule.Schedule'. See 'fromText' for details.
fromString :: String -> Either Parsec.ParseError Schedule.Schedule
fromString :: String -> Either ParseError Schedule
fromString = forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
Parsec.parse forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Schedule
parsec String
""

-- | Parses a strict 'Text.Text' value into a 'Schedule.Schedule'. The input
-- should have five fields, each separated by at least one space. Leading and
-- trailing spaces are allowed.
fromText :: Text.Text -> Either Parsec.ParseError Schedule.Schedule
fromText :: Text -> Either ParseError Schedule
fromText = forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
Parsec.parse forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Schedule
parsec String
""

parsec :: (Parsec.Stream s m Char) => Parsec.ParsecT s u m Schedule.Schedule
parsec :: forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Schedule
parsec =
  forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany (forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
' ')
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Schedule
Schedule.parsec
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany (forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char Char
' ')
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof