From dc9c54fdf2d855bf003d17d6ecd2829b44a8d0e0 Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Sun, 26 Dec 2021 22:58:03 +0000 Subject: [PATCH] Add a specific type for names (#2) --- FicroKanSharp.Test/TestTypedMatch.fs | 1 - FicroKanSharp/Typed.fs | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/FicroKanSharp.Test/TestTypedMatch.fs b/FicroKanSharp.Test/TestTypedMatch.fs index e2cb7c0..cebcdd4 100644 --- a/FicroKanSharp.Test/TestTypedMatch.fs +++ b/FicroKanSharp.Test/TestTypedMatch.fs @@ -1,2 +1 @@ module FicroKanSharp.Test.TestTypedMatch - diff --git a/FicroKanSharp/Typed.fs b/FicroKanSharp/Typed.fs index 76d2994..425bda0 100644 --- a/FicroKanSharp/Typed.fs +++ b/FicroKanSharp/Typed.fs @@ -7,6 +7,15 @@ type TypedTerm<'a> = | Term of Term | Literal of 'a +type internal TypeName<'a> = + { + UserType : Type + FieldValue : 'a + } + + override this.ToString () = + sprintf "%O<%s>" this.FieldValue this.UserType.Name + [] module TypedTerm = @@ -40,9 +49,15 @@ module TypedTerm = let valuesU = toTermList valuesU let td = typedefof<'a> - Term.Symbol ((td, fieldU.Name), valuesU) + Term.Symbol ( + { + UserType = td + FieldValue = fieldU.Name + }, + valuesU + ) else - Term.Symbol ((ty, t), []) + Term.Symbol ({ UserType = ty ; FieldValue = t }, []) and private ofLiteral : Type -> obj -> Term = let m =