Data.Text.Read Prelude> :set -XOverloadedStrings Prelude> :m +Data.Text.Read Prelude Data.Text.Read> decimal "123" Right (123,"") Prelude Data.Text.Read> decimal "abc" Left "input does not start with a digit&…
Data.Tree data Tree a = Node { rootLabel :: a, subForest :: Forest a } deriving (Eq, Read, Show) type Forest a = [Tree a] Data.Tree 是一种非空(存在根节点),可以有无限分支,每个节点均可有多路分支的Tree类型. Prelude Data.Tree> :t Node 1 Node 1 :: Num a => Forest a -> Tree a Prelud…
Data.Tuple fst :: (a,b) -> a fst (x,_) = x snd :: (a,b) -> b snd (_,y) = y curry :: ((a, b) -> c) -> a -> b -> c curry f x y = f (x, y) uncurry :: (a -> b -> c) -> ((a, b) -> c) uncurry f p = f (fst p) (snd p) swap :: (a,b) -…
Data.Typeable 利用 Data.Typeable,可以打印动态类型信息. class Typeable (a :: k) where typeRep# :: TypeRep a typeRep :: Typeable a => TypeRep a typeRep = typeRep# typeOf :: Typeable a => a -> TypeRep a typeOf _ = typeRep typeOf 函数可以返回某个值的类型信息. {-# LANGUAGE Der…