Haskell & Gereja ADT
data One = One deriving (Eq, Ord, Bounded, Enum, Show, Read)
Ini mendefinisikan satu yang benar One
. Ini One
adalah kedua jenis yang menunjukkan keesaan , dan konstruktor One
, yang itu sendiri fungsi nullary bahwa return yang satu benar, dan hanya satu nilai tipe One
, yaitu, lihatlah, One
.
Penggunaan dalam ghci
REPL:
λ: One -- One returns the one true One
One
λ: One == One -- One is equal to itself, as no others are
True
λ: One < One -- One is no less than itself
False
λ: minBound :: One -- One is the least One there is, yet it is all you need
One
λ: maxBound :: One -- One is as big as the universe of One, it is omnipotent
One
λ: [ One .. One ] -- One is the beginning, and ending, of all that is One
[One]
λ: show One -- The textual gospel of One
"One"
λ: read "One" :: One -- To read the word of One, is to become one with One
One
Buku lengkap One sekarang online. Memuat itu membuat Anda berdua wasiat: Komputasi dan Aritmatika. Ini memungkinkan Anda untuk mengeksplorasi lebih banyak kebenaran:
λ: One + One -- One can only add to its magnificence
One
λ: negate One
*** Exception: One cannot be negated, mortal fool!
λ: One `div` One -- One is indivisible
One
λ: One `mod` One
*** Exception: Nothing can modulate the power of One
λ: toRational One -- Ye shall know One as both Numerator and Denominator
1 % 1
λ: toInteger One * 42 -- One multiplies all to wholeness
42
λ: toRational One / 2 -- Even divided, One is on top
1 % 2