Skip to content

Instantly share code, notes, and snippets.

View CoditCompany's full-sized avatar
👋
You can find us on @CoditEU

Codit CoditCompany

👋
You can find us on @CoditEU
View GitHub Profile
let add4 a b c d = a + b + c + d
let pid = pipe4 (pstring "ITEM") (countString 3 digit) (pstring "-") (countString 2 caps) add4
let sentence = manyChars (letter <|> space)
let pdes = sentence
let pnotes = sentence
let pquantity = pint32
let punitprice = pfloat
let pcustomers = sepBy1 pcustomer newline |>> List.tryHead
let pcustomers = sepBy1 pcustomer newline
let pipe6 p1 p2 p3 p4 p5 p6 f =
pipe5 p1 p2 p3 p4 (tuple2 p5 p6)
(fun x1 x2 x3 x4 (x5, x6) -> f x1 x2 x3 x4 x5 x6)
type Customer =
{ Country : string
FullName : string
Street : string
City : string
State : string
PostalCode : string }
let customer country name street city state postal =
{ Country = country; FullName = name; Street = street ; State = state; City = city; PostalCode = postal }
let country = countString 10 (caps <|> space)
let fullname = countString 20 (letter <|> space)
let street = countString 20 (letter <|> space <|> digit)
let city = countString 15 (letter <|> space)
let state = countString 3 (caps <|> space)
let postal = countString 5 (caps <|> digit <|> space)
let trim (s : string) = s.Trim ()
let countString n p = count n p |>> (string' >> trim)
let space = pchar ' '
let caps = anyOf [ 'A'..'Z' ]