Category class Category cat where id :: cat a a (.) :: cat b c -> cat a b -> cat a c instance Category (->) where id = GHC.Base.id (.) = (GHC.Base..) (<<<) :: Category cat => cat b c -> cat a b -> cat a c (<<<) = (.) (&…
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.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…
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…