Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:37:23+00:00 2026-06-03T14:37:23+00:00

Are there some ‘date parser’ library that does for dates what FParsec does to

  • 0

Are there some ‘date parser’ library that does for dates what FParsec does to strings ?

That is, you either specify rules and it will match against them to recognize the supplied patterns.


Conversely, are there any libraries to generate dates based on some parsing rules ?
The idea would be to supply user with a ‘real time’ completion to guide him to a valid future fparsec matching.

(does this problem of generative parsing has a name in the secluded parsing circles ?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:37:26+00:00Added an answer on June 3, 2026 at 2:37 pm

    You can define a simple domain specific language (DSL) to express these kinds of rules. The type corresponding to your “parser” is actually just a function that takes a date and returns boolean:

    type DateClassifier = DC of (DateTime -> bool)
    

    You can easily define some simple functions:

    // Succeeds when the date is wednesday
    let wednesday = DC (fun dt -> dt.DayOfWeek = DayOfWeek.Wednesday)
    
    // Succeeds if the date is after specified limit
    let after limit = DC (fun dt -> dt > limit)
    
    // Succeeds if the day is the specified value
    let day d = DC (fun dt -> dt.Day = d)
    
    // Takes two date classifiers and succeeds if either of them succeeds
    let (<|>) (DC f) (DC g) = (fun dt -> f dt || g dt)
    
    // Takes two date classifiers and succeeds if both of them succeed
    let (<&>) (DC f) (DC g) = (fun dt -> f dt && g dt)
    

    To specify your condition – “the next wednesday after the 5th of the month” – you’ll need a helper that generates function that succeeds on any day following 5th, which can be done like this (this is a bit inefficient, but it is composition using existing primitives, which is nice):

    let afterDay d = 
      [ for n in d + 1 .. 31 -> day n ] |> Seq.reduce (<|>)
    

    Your specification (or “parser”) that only succeeds for the day you described is then:

    after DateTime.Now (wednesday <&> afterDay 5)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some implementation of java.util.Map that does not uses HashCode? I have the
Are there some way to execute a SSIS Package that I have in a
Is there some gem or technique that will let us write only .html.erb templates
Is there some combination of keys or a menu option that I can use
Is there some standard method to remove all characters from string that cannot be
Is there some Haskell function that can take a list, say of doubles, like
Is there some function/procedure/package that validates a username and password in Oracle (from a
Is there some openCV function that I can pass in a cv::Mat and get
Is there some way that I can determine if a MailItem is being opened
Is there some kind of tool/plugin (preferably for eclipse) that would allow me to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.