Abstract type: Difference between revisions
Content added Content deleted
(!= ocaml abstract type) |
|||
Line 83: | Line 83: | ||
<ocaml>type t</ocaml> |
<ocaml>type t</ocaml> |
||
it is used for example to hide an implementation from the interface of a module or for type algebra. |
it is used for example to hide an implementation from the interface of a module or for type algebra. |
||
Example of abstracting a type in an interface: |
|||
<ocaml>module Foo : sig |
|||
type t |
|||
end = struct |
|||
type t = int * int |
|||
end</ocaml> |
|||
Pure abstract types in the implementation: |
|||
<ocaml>type u |
|||
type v |
|||
type 'a t |
|||
type ut = u t |
|||
type vt = v t</ocaml> |
|||
=={{header|Python}}== |
=={{header|Python}}== |