Several features of Haskell/GHC have low googleability.
Because some of them are composed of symbols :)
This page is a reference collection to support search of them.
If you want to search for function symbols like <*>
, $
, .
, >>=
, ..., you can use the following search engines:
- Hoogle search on Stackage
- Hoogle on Haskell.org
- Aelve Codesearch (used "in the wild", and regex support)
Happy Haskelling!
[ Haskell 2010 Language Report ]
data Vec = Vec !Int
[ GHC User’s Guide ]
f1 !x =
[ GHC User’s Guide ]
data Int = I# Int#
[ GHC User’s Guide ]
example = #x (Point 1 2)
[ GHC User’s Guide ]
two = $(add1 1)
[ GHC User’s Guide ]
two = $$(add1 1)
'
: an identifier consists of a letter followed by zero or more letters, digits, underscores, and single quotes
[ Haskell 2010 Language Report ]
xs' = f ys
[ GHC User’s Guide ]
type * = TYPE 'LiftedRep
[ GHC User’s Guide ]
makeLenses ''FooBar
[ Haskell 2010 Language Report ] [ Haskell 2010 Language Report ]
main :: IO ()
[ Haskell 2010 Language Report ] [ Haskell 2010 Language Report ]
return ()
[ Haskell 2010 Language Report ]
add1 = (1+)
[ Haskell 2010 Language Report ]
f x y = liftM2 (,) x y
[ GHC User’s Guide ]
f x y = (# x+1, y-1 #)
[ GHC User’s Guide ]
f :: (# Int | Bool | Char #) -> Int
f (# x | | #) = 1
f (# | True | #) = 2
f _ = 3
[ Haskell 2010 Language Report ]
module GHC.Arr (
Ix(..),
[ Haskell 2010 Language Report ]
import GHC.Types (Bool(..))
[ Haskell 2010 Language Report ] [ GHC User’s Guide ] [ GHC User’s Guide ]
ghci> :kind Int
Int :: *
[ Haskell 2010 Language Report ]
f x = case x of
Nothing -> False
Just _ -> True
[ GHC User’s Guide ]
size (view -> Unit) = 1
size (view -> Arrow t1 t2) = size t1 + size t2
[ Haskell 2010 Language Report ]
id :: a -> a
[ Haskell 2010 Language Report ]
import Data.Maybe
import qualified Text.Read.Lex as L
lexP = lift L.lex
[ GHC User’s Guide ]
f :: forall a. a -> [a]
[ Haskell 2010 Language Report ] [ Haskell 2010 Language Report ] [ Haskell 2010 Language Report ]
f x xs = x:xs
[ Haskell 2010 Language Report ]
data NonEmpty a = a :| [a]
[ Haskell 2010 Language Report ]
id :: a -> a
id x = x
[ Haskell 2010 Language Report ]
x = fromIntegral (maxBound::Int)
[ Haskell 2010 Language Report ]
f x = let a = 1; b = 2
g y = exp2
in exp1
[ Haskell 2010 Language Report ]
f = do
x <- getLine
putStrLn x
[ Haskell 2010 Language Report ]
f x
| Just y <- g x =
[ Haskell 2010 Language Report ]
subtract :: (Num a) => a -> a -> a
subtract x y = y - x
[ Haskell 2010 Language Report ]
f s@(x:xs) =
[ GHC User’s Guide ]
f = read @Int
[ Haskell 2010 Language Report ] [ Haskell 2010 Language Report ]
null [] = True
null _ = False
[ Haskell 2010 Language Report ]
xs = [1..10]
[ Haskell 2010 Language Report ]
xs = [x^2 | x <- [1..10]]
[ GHC User’s Guide ]
add1 x = [| x + 1 |]
[ GHC User’s Guide ]
add1 x = [|| x + 1 ||]
[ Haskell 2010 Language Report ]
f Red =
f Blue =
f _ =
[ GHC User’s Guide ] [ Haskell 2010 Language Report ]
_w = True -- No warning: _w starts with an underscore
[ GHC User’s Guide ]
sum xs = foldr _ 0 xs
[ GHC User’s Guide ]
million = 1_000_000
[ Haskell 2010 Language Report ]
add1 = \x -> x + 1
[ GHC User’s Guide ]
f = \case
Red -> 2
Blue -> 1
_ -> 0
[ Haskell 2010 Language Report ]
div10 x = x `div` 10
[ Haskell 2010 Language Report ]
f x = case x of {Nothing -> False; Just _ -> True}
[ Haskell 2010 Language Report ]
data MyPoint = Point { x :: Int, y :: Int }
[ GHC User’s Guide ]
f Vec{..} =
[ Haskell 2010 Language Report ] [ GHC User’s Guide ] [ GHC User’s Guide ]
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE GADTs #-}
{-# INLINE fmap #-}
[ Haskell 2010 Language Report ]
clip255 x
| x > 255 = 255
| otherwise = x
[ GHC User’s Guide ]
if | x == ":q" -> quit
| isError x -> errorExit x
| otherwise -> execCommand x
[ Haskell 2010 Language Report ]
data Maybe a = Nothing | Just a
[ GHC User’s Guide ]
class Foo a b c | a b -> c where
[ Haskell 2010 Language Report ]
f1 ~(as,bs) =
[ GHC User’s Guide ]
class (F a ~ b) => C a b where