F# 新手,不知道如何修复 FS0025 错误

New to F# and Don't Know How to Fix FS0025 error

我正在努力自学 F#(我的第一门函数式编程语言),方法是构建一个非常重要的应用程序(或尝试),该应用程序将记录用户输入并写入 JSON 文件(或最终,一个数据库)贫穷的人口贩运幸存者向美国所有反人口贩运 charities/NGO 提出的帮助请求的结果。在尝试了我能想到的一切以确保考虑了相关模式的所有可能情况之后,我不断收到此错误。我不知道如何修复它,我真的不能在这个应用程序上使用任何错误抑制。任何帮助都将不胜感激,因为我没有其他人可以寻求任何帮助和支持。这是 TerminalBuilder.fs 文件中的代码:

namespace Nonprofits

module TerminalBuilder =
    open System
    open System.IO
    open Nonprofits.Types

    let rec caller():Caller =
        printfn "Are you reporting as an advocate on behalf of someone else or for yourself?"
        printfn " 1 for Advocate"
        printfn " 2 for Self"
        let answer = Console.ReadLine()
        match answer with
        | "1" -> Advocate
        | "2" -> ClientOrVictim 
        | _ -> printfn "Invalid Entry"
               caller()

    let specialneeds():Set<Disability> =
        let rec spnds(s:Set<Disability>): Set<Disability> =
            printfn "Do you/the person on whose behalf you're reporting have any disabling conditions?"
            printfn " 1 for Learning Disability"
            printfn " 2 for Physical Disability"
            printfn " 3 for Mental Health Issues"
            printfn " 4 for Substance Addiction Issues"
            printfn " 5 for Pregnancy-Related Limitations"
            printfn " 6 for Chronic Illness"
            printfn " 7 for Don't KNow/Undiagnosed"
            printfn " Enter 'Exit' for None"
            let answer = Console.ReadLine()
            match answer.Trim().ToLower() with
            | "exit" -> s
            | _ -> 
                let sn =
                    match answer.Trim().ToLower() with
                    | "1" -> Some LearningDisabled
                    | "2" -> Some PhysicallyDisabled
                    | "3" -> Some MentalIllness
                    | "4" -> Some SubstanceAddiction
                    | "5" -> Some Pregnancy
                    | "6" -> Some ChronicIllness
                    | "7" -> Some Undiagnosed
                    | "exit" -> printfn "No disabling conditions"
                                None
                match sn with
                | None -> spnds(s)
                | Some (x) -> spnds(s.Add(x))
        spnds(new Set<Disability> ([]))

这是我的类型文件,Nonprofits.fs:

namespace Nonprofits

open System.Collections

module Types =

    type NgoType =
        | HomelessShelter
        | DVShelter
        | TraffickingVictimSafehouse
        | TraffickingSurvivorAftercare // gamut of legal, housing, clothing, food, medical, reintegration, etc.
        | FoodPantries
        | ClothingAssistance
        | FreeMedicalDentalClinic

    type Ngo = Ngo of NgoType * string 


    type Caller =
        | ClientOrVictim 
        | Advocate

    and CallerStatus =
        | VictimServicesAdvocate of Caller
        | DVvictim of Caller
        | SexTraffickingSurvivor of Caller
        | HomelessVictim of Caller
        | NaturalDisasterVictim of Caller
        | GeneralPovertyVictim of Caller

    and Disability =
        | Pregnancy 
        | PhysicallyDisabled 
        | LearningDisabled 
        | MentalIllness 
        | SubstanceAddiction 
        | ChronicIllness 
        | Undiagnosed 

    and SpecialNeeds = SpecialNeeds of Set<Disability>

    type UnmetNeeds =
        | TraffickingSafebed
        | DVsafebed  
        | Housing
        | Clothing
        | Food
        | Legal 
        | Medical
        | Dental
        | Vision
        | DrugRehab
        | TraumaCare
        | PsychiatricCare
        | SkillsTraining
        | EducationHelp
        | JobPlacement
        | EconomicSupport

    type CallerRequest =
        | TraffickingVictimAftercare of Set<UnmetNeeds>
        | PovertyVictimCare of Set<UnmetNeeds>

    type Followup =
        | SocialWorkerFollowup of Help
        | CallerSelfDirected of Help

    and Help =
        | Helped //fully helped with everything caller needed
        | ExhaustedOptions // exhausted resources and still not helped
        | WrongHelp //i.e. caller offered smoking cessation counseling when caller needed sex trafficking aftercare
        | NotHelped of Followup
        | GivenReferral of ReferredToNextNgo

    and ReferredToNextNgo = ReferredToNextNgo of Followup * Ngo

    type CallOutcome =
        | CallerHelped
        | CallerNotHelped of Followup
        | CallerReferred of ReferredToNextNgo


    type Call = Call of Caller * CallerRequest * CallOutcome

这是我遇到的错误:

C:\UsersCU1501060\Documents\Projects\DUandTypesPractice\DUandTypesPractice\TerminalBuilder.fs(27,27): Warning FS0025: Incomplete pattern matches on this expression. For example, the value '"a"' may indicate a case not covered by the pattern(s). (FS0025) (DUandTypesPractice)

当你进行模式匹配时

      let sn =
                match answer.Trim().ToLower() with
                | "1" -> Some LearningDisabled
                | "2" -> Some PhysicallyDisabled
                | "3" -> Some MentalIllness
                | "4" -> Some SubstanceAddiction
                | "5" -> Some Pregnancy
                | "6" -> Some ChronicIllness
                | "7" -> Some Undiagnosed
                | "exit" -> printfn "No disabling conditions"
                            None

```

你勾选了“1”、“2”、……"exit",但是还有其他的值,比如"a",你需要再加一个case

| answer -> //do something

你的情况可能

| answer -> printfn "not supported answer %A" answer
            None // or retry?

编译器在帮你,告诉你"what happen if user choose 'a'"?