Haskell 狀態Monad (State Monad)的理解

一、State s a數據類型 State s a是一種用來封裝狀態處理函數:\s -> (a,s’)的數據結構,由於State封裝的是一個函數,而不是狀態s自己,因此稱State爲State類型(type)是不許確的,應該把State s a稱爲狀態處理器(State processor)。web newtype State s a = State { runState :: s -> (a,s
相關文章
相關標籤/搜索