| Both sides previous revisionPrevious revision | |
| codesnippets:prelude:basictypeclasses [2021/04/10 19:20] – [xyz] f2b216 | codesnippets:prelude:basictypeclasses [2021/04/10 19:49] (current) – removed f2b216 |
|---|
| ====== Basic type classes ====== | |
| |
| ===== Eq ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#g:4|class Eq a]] | |
| * main functions | |
| * ''%%(==)%%'' ''%%:: a -> a -> Bool%%'' ''infix 4'', true if equal otherwise false | |
| * ''%%(/=)%%'' ''%%:: a -> a -> Bool%%'' ''infix 4'', false if equal otherwise true | |
| * Minimal complete definition: either ''%%==%%'' or ''%%/=%%''. | |
| |
| ===== Ord ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Ord|class Eq a => Ord a]] | |
| * main functions | |
| * ''%%compare%%'' ''%%:: a -> a -> Ordering%%'' | |
| * LT if first parameter is less then second parameter, | |
| * EQ if first parameter is equal second parameter, and | |
| * GT if first parameter is greater then second parameter | |
| * ''%%(<)%%'' ''%%:: a -> a -> Bool%%'' ''infix 4'', true if first parameter is less than second parameter otherwise false | |
| * ''%%(<=)%%'' ''%%:: a -> a -> Bool%%'' ''infix 4'', true if first parameter is equal or less than second parameter otherwise false | |
| * ''%%(>)%%'' ''%%:: a -> a -> Bool%%'' ''infix 4'', true if first parameter is greater than second parameter otherwise false | |
| * ''%%(>=)%%'' ''%%:: a -> a -> Bool%%'' ''infix 4'', true if first parameter is equal or greater than second parameter otherwise false | |
| * ''%%max%%'' ''%%:: a -> a -> a%%'' the greater or equal value of both parameters | |
| * ''%%min%%'' ''%%:: a -> a -> a%%'' the smaller or equal value of both parameters | |
| * Minimal complete definition: either compare or ''%%<=%%''. Using compare can be more efficient for complex types. | |
| |
| ===== Enum ===== | |
| |
| * [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Enum|class Enum a]] | |
| * main functions | |
| * ''%%succ%%'' ''%%:: a -> a%%'' | |
| * ''%%pred%%'' ''%%:: a -> a%%'' | |
| * ''%%toEnum%%'' ''%%:: Int -> a%%'' | |
| * ''%%fromEnum%%'' ''%%:: a -> Int%%'' | |
| * ''%%enumFrom%%'' ''%%:: a -> [a]%%'' | |
| * ''%%enumFromThen%%'' ''%%:: a -> a -> [a]%%'' | |
| * ''%%enumFromTo%%'' ''%%:: a -> a -> [a]%%'' | |
| * ''%%enumFromThenTo%%'' ''%%:: a -> a -> a -> [a]%%'' | |
| |
| ===== Bounded ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Bounded|class Bounded a]] | |
| |
| ===== Num ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Num|class Num a]] | |
| |
| ===== Real ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Real|class (Num a, Ord a) => Real a]] | |
| |
| ===== Integral ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Integral|class (Real a, Enum a) => Integral a]] | |
| |
| ===== Fractional ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Fractional|class Num a => Fractional a]] | |
| |
| ===== RealFrac ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:RealFrac|class (Real a, Fractional a) => RealFrac a]] | |
| |
| ===== Semigroup ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Semigroup|class Semigroup a]] | |
| |
| ===== Monoid ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Monoid|class Semigroup a => Monoid a]] | |
| |
| ===== Functor ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Functor|class Functor f]] | |
| |
| ===== Applicative ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Applicative|class Functor f => Applicative f]] | |
| |
| ===== Monad ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Monad|class Applicative m => Monad m]] | |
| |
| ===== MonadFail ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:MonadFail|class Monad m => MonadFail m]] | |
| |
| ===== Foldable ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Foldable|class Foldable t]] | |
| |
| ===== Traversable ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Traversable|class (Functor t, Foldable t) => Traversable t]] | |
| |
| ===== Show ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Show|class Show a]] | |
| |
| ===== Read ===== | |
| |
| * source: [[https://hackage.haskell.org/package/base-4.15.0.0/docs/Prelude.html#t:Read|class Read a]] | |
| |
| |