discriminated-union
Transform an Abstract Syntax Tree (AST) in F#
I am trying to design an AST for a decision logic table.One of the things I would like to be able to do with the discriminated union that represents my AST is transform parts of it for different reaso[详细]
2023-04-05 23:06 分类:问答Printing F# discriminated union
I am writing a F# program which parses a string into a AST type which is a discriminated union. When I use fsi (on Mono + Mac OS X) to run my code, the AST is printed out in a nice format. But when[详细]
2023-04-05 06:27 分类:问答Immutable fields in discriminated union
I know it\'s possible to add methods and properties to discriminated unions, but can you add an immutable field that has to be set when an instance the union is created, much like the fields in a reco[详细]
2023-04-03 14:36 分类:问答F# discriminated unions versus C# class hierarchies
I have the following code: public abstract class A ... public class B : A ... public class C : A ... void my_fct(A x) {[详细]
2023-04-03 11:05 分类:问答Choosing whether to use Discriminated Unions or Record Types for a small AST in F#
Let\'s say I am implementing a very simple toy language parser. I am deciding whether to use DUs or record types (maybe a mix of both?). The structure of the language would be:[详细]
2023-03-30 06:55 分类:问答Higher verbosity when using Record types in F# in comparison with Discriminated Unions
let Method = { Name:string } //oversimplification let method_parser = spaces >>. many1Satisfy isLetter .>> spaces[详细]
2023-03-30 06:40 分类:问答Conversion between types in discriminated unions
I have a function, which can returns different types, and I use discriminated union for this. What I need, is to have conversion from one type in discriminated union to another type.[详细]
2023-02-17 02:42 分类:问答Type-safe discriminated unions in C#, or: How to limit the number of implementations of an interface?
First, sorry for the lengthy post. Basically, my question is this: I\'m trying to reproduce the following F# discriminated union type in C#:[详细]
2023-02-16 05:02 分类:问答Match on discriminated union
Using F# for the first time for a production thing and need a little help. Please see this code where I added the warnings I get as comments on each line:[详细]
2023-02-12 22:29 分类:问答F# discriminated union picking 0 or 1 from a list
Given a mapping program where I map from an array of strings to a discriminated union, I want to select an instance of a particular DU type. I know that there will be 0 or 1 instances. Is there a smar[详细]
2023-01-22 17:28 分类:问答