-
Notifications
You must be signed in to change notification settings - Fork 1
/
B2.fs
41 lines (32 loc) · 1.03 KB
/
B2.fs
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
40
41
module BrandX.B2
open BrandX.Structures
open FParsec
open System
open System.Collections.Generic
open System.IO
//Beginning Segment for Shipment Information Transaction
type StdCarAlphaCode =
| StdCarAlphaCode of string
let pStdCarAlphaCode : Parser<Option<StdCarAlphaCode>> =
opt ((manyMinMaxSatisfy 2 4 isAsciiLetter |>> StdCarAlphaCode))
.>> pOFSep
type ShipIdNo =
| ShipIdNo of string
let pShipIdNo : Parser<Option<ShipIdNo>> =
opt
(manyMinMaxSatisfy 1 30 (fun c -> isDigit c || isAsciiLetter c)
|>> ShipIdNo) .>> pOFSep
type ShipPmt =
| Collect
| Prepaid
| ThirdPartyPay
let pShipPmt : Parser<ShipPmt> =
(skipString "PP" >>? preturn Prepaid)
<|> (skipString "CC" >>? preturn Collect)
<|> (skipString "TP" >>? preturn ThirdPartyPay)
type B2 =
| B2 of Option<StdCarAlphaCode> * Option<ShipIdNo> * ShipPmt
// B2**BLNJ**BLNJ75035079T**PP~
let pB2 : Parser<B2> =
skipString "B2" >>. pOFSep
>>. tuple3 pStdCarAlphaCode pShipIdNo pShipPmt |>> B2 .>> pRSep