Created
August 28, 2015 09:31
-
-
Save ChrisDobby/5854e2faceab3e92b9be to your computer and use it in GitHub Desktop.
Visitor in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Visitor | |
type IPrescription = | |
abstract member Accept : IPrescriptionVisitor -> unit | |
and IPrescriptionVisitor = | |
abstract member Visit : PointInTime -> unit | |
abstract member Visit : Infusion -> unit | |
and PointInTime() = | |
interface IPrescription with | |
member this.Accept visitor = visitor.Visit this | |
and Infusion() = | |
interface IPrescription with | |
member this.Accept visitor = visitor.Visit this | |
type PrescriptionLabelVisitor() = | |
interface IPrescriptionVisitor with | |
member this.Visit (prescription : PointInTime) = printf "********** Label for point in time dose\n\n" | |
member this.Visit (prescription : Infusion) = printf "********** Label for infusion\n\n" | |
type PrescriptionPrintoutVisitor() = | |
interface IPrescriptionVisitor with | |
member this.Visit (prescription: PointInTime) = printf "********** Printout for point in time dose\n\n" | |
member this.Visit (prescription: Infusion) = printf "********** Printout for infusion\n\n" | |
type PrescriptionCsvVisitor() = | |
interface IPrescriptionVisitor with | |
member this.Visit (prescription: PointInTime) = printf "********** Csv for point in time dose\n\n" | |
member this.Visit (prescription: Infusion) = printf "********** Csv for infusion\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment