[MLton-user] datatypes, opaque ascription and case ... of

Tom 7 twm@andrew.cmu.edu
Sun, 24 Oct 2004 15:18:14 -0400 (EDT)


If I understand you correctly, I think a cleaner solution would look like 
this:

signature RETE_NODE =
sig

    type rete_beta_data
    type rete_join_data
    type rete_cc_data
    ...

    datatype rete_node =
         TBetaNode of rete_beta_data
       | TJoinNode of rete_join_data
       | TNCCNode  of rete_cc_data
       | ...
end

This way you can implement your datatype exactly as you already have (no 
extra conversion overhead), but hold exactly the appropriate parts 
abstract.


  - Tom


> Is there some other trick??
> 
> In summary, I want to expose a datatype just enough to perform a "case
> .. of" on it but all other internal knowledge about the datatype remains
> opaque.
>
> signature RETE_NODE =
> sig
>
> datatype rete_node_type = TBetaNode | TJoinNode | TNCCNode | so on
>
> type rete_node
>
> val reteNodeType: rete_node -> rete_node_type
>
> end
>
> structure ReteNode:> RETE_NODE =
> struct
>
> datatype rete_node = THAT REALLY HAIRY MESS ABOVE
>
> datatype rete_node_type = TBetaNode | TJoinNode | TNCCNode | so on
>
> fun reteNodeType rnode = case rnode of
>                                    BetaNode _ => TBetaNode
>                                  | JoinNode _ => TJoinNode
>                                  | so on and so on
> end
>
> Is there some other trick??
>
> In summary, I want to expose a datatype just enough to perform a "case
> .. of" on it but all other internal knowledge about the datatype remains
> opaque.
>
> God, I hope I got this across ok.
>
> Thanks in advance.
>
> Ray
>
>
> _______________________________________________
> MLton-user mailing list
> MLton-user@mlton.org
> http://www.mlton.org/mailman/listinfo/mlton-user
>
>


[ NEW! : http://tom7.org/       ]
[ OLD! : http://fonts.tom7.com/ ]