私はこの記録を持っています:
type Client =
{ Name : string; Income : int ; YearsInJob : int
UsesCreditCard : bool; CriminalRecord : bool }
このレコードのジェネレーターを作成するために、次のコードを試しました。
let chooseFromList xs =
gen {
let! idx = Gen.choose(0, List.length xs - 1)
return (List.nth xs idx)
}
let generateName = (Gen.oneof [ gen {return "A"};gen {return "B"};gen {return "C"}])
let generateIncome= (chooseFromList [0..5000])
let generate_YearsInJob= chooseFromList [0..45]
let generate_UsesCreditCard = (Gen.oneof [ gen { return true }; gen { return false } ])
let generate_UsesCriminalRecord= (Gen.oneof [ gen { return true }; gen { return false } ])
let genertate_Client =
{
Name= generateName;
Income=generateIncome;
YearsInJob=generate_YearsInJob
UsesCreditCard=generate_UsesCreditCard
CriminalRecord=generate_UsesCriminalRecord
}
問題はName= generateName;
次のとおりです。エラーが発生しています:
This expression was expected to have type string,but here has type Gen<string>
このエラーは、最後の残りの行に存在します。