Type Synonyms in FSharp

Viewed 225

If I declare a type in FSharp like this:

type Dog = {Id:int;Name;String}

and I want to create a synonym in the code base

type Pooch = {Id:int;Name;String}

and I want to use either type interchangably. Sometimes "Dog" and sometimes "Pooch". I was thinking of doing somekind of OO technique where Pooch inherits from Dog -> though in reality Dog can inherit for Pooch just as a Pooch can inherit from Dog.

Is there a language construct that allows type synonyms in FSharp? Does any language support it? Note that this example goes against all software engineering rules where you should only use one word to represent one thing :-)

1 Answers

I think I just answered my own question

type Dog = {Id:int; Name:string}
type Pooch = Dog

Thanks

Related