aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/src/Text/Edifact/Common.hs
blob: c938d48470e9f30e660314ccd98dfbc8d0bd9cfe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{-|
Module      : Text.Edifact.Common
Description : Common syntax

This module should handle the main revision of the Edifact specification, which
covers UN* segments.

Currently it barely covers the revision 3 and this has not been scaffolded.

One future evolution will be to scaffold the various revisions from a more
general specification.
 -}
module Text.Edifact.Common
  (
    -- * Routine
    parseFull

    -- * Reexports
  , ParseError
  , Parser
  , Text
  ) where

import           Text.Edifact.Parsing
import           Text.Edifact.Parsing.Commons

import           Text.Edifact.Common.Segments

import           Data.Text                    (Text)

parseFull :: Parser value -> Text -> Either ParseError value
parseFull = parse . fullSyntaxParser

fullSyntaxParser :: Parser a -> Parser a
fullSyntaxParser messageParser =
  segmentUNA >>
  tries [ segmentUNB *> messageParser <* segmentUNZ
        , messageParser
        ]