I am trying to do this:
type TS1<'state, 'action> = { actions : 'state -> #seq<'action> move : 'state -> 'action -> 'state state0 : 'state }
But type checking doesn't let me:
.../stdin(2,29):error FS0715: Anonymous type variables are not permitted in this declaration
However, if I breed the definition of a flexible type, I am fine:
type TS2<'state, 'action, 'actions when 'actions :> seq<'action>> = { actions : 'state -> 'actions move : 'state -> 'action -> 'state state0 : 'state }
I don't like adding a variable like 'actions - this makes connecting to deterministic transition systems, as mathematical objects are less obvious.
I donโt see what could go wrong if flexible types are allowed in record definitions. Is it somehow dangerous? Is there any other way to get the clarity of the definition I would like?
Update . I was hoping I could write functions on TS types that use well-known implementations; that is, I want to be able to define a function
let has_action a ts s = Set.contains a <| ts.actions s
This will not explicitly be printed if the member type is actions : 'state -> seq<'action> . I can do this with the second definition, in which case has_action is of type
has_action : a:'a -> ts:TS2<'s,'a,Set<'a>> -> s: -> bool when 'a : comparison
The type of this example suggests that the flexible type in TS1 might not have helped. Can't I avoid a useless third type parameter in TS2? It seems to me that the exact implementation of a collection of actions for a state is an implementation detail that should not be displayed in a type.