Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-908

Make required types actually required by the Haskell type system

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.6
    • 0.9.2
    • None
    • Patch Available

    Description

      Currently Haskell bindings consider all struct fields to be optional by having all struct fields be "Maybe $field". This patch removes that Maybe for required fields.

      THIS BREAKS EXISTING CODE.

      It's also probably incomplete – I haven't looked too carefully yet at what happens on the server side if it tries to parse out an incomplete struct definition:

      struct myStruct {
        1: required byte foo,
      }
      

      became after some code changes

      struct myStruct {
        1: optional byte foo,
      }
      

      And code generated for the first version is asked to read a struct from the second version where foo is missing.

      I suspect after this patch the Haskell server commits hara-kiri trying to evaluate undefined outside of the thrift generated code (so the client could would receive an error for something that the thrift generated code should have noticed as wrong). This is clearly inadequate.

      Consider this bug a thought experiment / request for comments until I validate that the patch is complete. It will still break existing code.

      First and foremost:

      1. Thoughts?
      2. What would be an acceptable way to handle the case described above for other Haskell users? Break the current interface some more by returning some error type (Either $struct $errMessags?). Throw a Haskell exception?
      3. How do the other bindings handle parsing invalid data off the network?
      4. The generator and generated code is fairly painful to read. Would the powers that be welcome a cleanup patch that moves as much of the t_hs_generator.cpp code to a boost::format-style system that uses template strings that look like Haskell code, and reformats the output to be indented, proper style Haskell code as much as possible?

      Attachments

        Issue Links

          Activity

            People

              roger Roger Meier
              clavoie Christian Lavoie
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 6h
                  6h
                  Remaining:
                  Remaining Estimate - 6h
                  6h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified