通過datatypes關(guān)鍵字來構(gòu)建自己的數(shù)據(jù)類型。
datatypes mytype = TwoInts of int * int
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ?Str of string
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ?Pizza
其中TwoInts和Str是構(gòu)造函數(shù),它們的作用是把對應(yīng)類型的數(shù)據(jù)轉(zhuǎn)換成mytype類型。Pizza是mytype類型的一個數(shù)據(jù)。
構(gòu)建了數(shù)據(jù)類型之后,如何讀取數(shù)據(jù)就是關(guān)鍵了。讀取數(shù)據(jù)分為兩個層次,一個是數(shù)據(jù)是從哪里來的,一個是數(shù)據(jù)自身是什么。

ML語言通過模式匹配來進行讀取數(shù)據(jù)。