开源软件名称(OpenSource Name): takenobu-hs/haskell-symbol-search-cheatsheet开源软件地址(OpenSource Url): https://github.com/takenobu-hs/haskell-symbol-search-cheatsheet开源编程语言(OpenSource Language): 开源软件介绍(OpenSource Introduction):
Haskell/GHC symbol search cheatsheet
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:
Happy Haskelling!
!
: "strictness flag"
[ Haskell 2010 Language Report ]
!
: "bang pattern"
[ GHC User's Guide ]
#
: "MagicHash"
[ GHC User's Guide ]
#
: "OverloadedLabels"
[ GHC User's Guide ]
#
: C pre-processor's directive
[ GHC User's Guide ]
#
: hsc2hs command's operator
[ GHC User's Guide ]
flag = # const VER_MAJORVERSION
$( )
: Template Haskell’s splice syntax
[ GHC User's Guide ]
$$( )
: Typed Template Haskell’s splice syntax
[ GHC User's Guide ]
%1 ->
: "Linear types"
[ GHC User's Guide ]
'
: an identifier consists of a letter followed by zero or more letters, digits, underscores, and single quotes
[ Haskell 2010 Language Report ]
'
: promoted constructors are prefixed by a tick '
[ GHC User's Guide ]
'
''
: Template Haskell’s quotation syntax
[ GHC User's Guide ]
()
: "unit type"
[ Haskell 2010 Language Report ]
[ Haskell 2010 Language Report ]
()
: "unit expression"
[ Haskell 2010 Language Report ]
[ Haskell 2010 Language Report ]
( )
: "section" - a convenient syntax for partial application
[ Haskell 2010 Language Report ]
(,)
: the constructor for a tuple
[ Haskell 2010 Language Report ]
(, xxx)
: "TupleSections"
[ GHC User's Guide ]
(# #)
: "unboxed tuple"
[ GHC User's Guide ]
(# | | #)
: "unboxed sum"
[ GHC User's Guide ]
f :: (# Int | Bool | Char # ) -> Int
f (# x | | # ) = 1
f (# | True | # ) = 2
f _ = 3
(..)
: export all of its names
[ Haskell 2010 Language Report ]
(..)
: import all of its names
[ Haskell 2010 Language Report ]
import GHC.Types (Bool (.. ))
*
: the kind of ordinary types (synonym for Type
and TYPE `LiftedRep
)
[ Haskell 2010 Language Report ]
[ GHC User's Guide ]
[ GHC User's Guide ]
->
: case expression
[ Haskell 2010 Language Report ]
f x = case x of
Nothing -> False
Just _ -> True
->
: "view pattern"
[ GHC User's Guide ]
size (view -> Unit ) = 1
size (view -> Arrow t1 t2) = size t1 + size t2
->
: "function type"
[ Haskell 2010 Language Report ]
.
: module names are a dot-separated sequence
[ Haskell 2010 Language Report ]
import Data.Maybe
import qualified Text.Read.Lex as L
lexP = lift L. lex
.
: "OverloadedRecordDot"
[ GHC User's Guide ]
getResult c = c. result
getResults = map (. result)
.
: "OverloadedRecordUpdate" (experimental)
[ GHC User's Guide ]
setYearTaken c y = c{taken. year = y}
.
: universal quantification
[ GHC User's Guide ]
:
: "list constructor" (cons)
[ Haskell 2010 Language Report ]
[ Haskell 2010 Language Report ]
[ Haskell 2010 Language Report ]
:
: an operator symbol starting with a colon is a constructor
[ Haskell 2010 Language Report ]
data NonEmpty a = a :| [a]
::
: "type signature"
[ Haskell 2010 Language Report ]
::
: "expression type-signature" (type annotation)
[ Haskell 2010 Language Report ]
x = fromIntegral (maxBound :: Int )
;
: semicolon in layout rule
[ Haskell 2010 Language Report ]
f x = let a = 1 ; b = 2
g y = exp2
in exp1
<-
: lambda-bound in do expression
[ Haskell 2010 Language Report ]
f = do
x <- getLine
putStrLn x
<-
: "pattern guard"
[ Haskell 2010 Language Report ]
=>
: context (type class constraint)
[ Haskell 2010 Language Report ]
subtract :: (Num a ) => a -> a -> a
subtract x y = y - x
?
: "ImplicitParams"
[ GHC User's Guide ]
sort :: (? cmp :: a -> a -> Bool ) => [a ] -> [a ]
sort = sortBy ? cmp
@
: "as pattern"
[ Haskell 2010 Language Report ]
@
: "type application"
[ GHC User's Guide ]
[]
: "empty list" (nil)
[ Haskell 2010 Language Report ]
[ Haskell 2010 Language Report ]
null [] = True
null _ = False
[ .. ]
: "arithmetic sequence"
[ Haskell 2010 Language Report ]
[ | <- ]
: "list comprehension"
[ Haskell 2010 Language Report ]
xs = [x^ 2 | x <- [1 .. 10 ]]
[| |]
, [e| |]
, [d| |]
, [t| |]
, [p| |]
: Template Haskell’s quotation syntax (expression, declaration, type, and pattern)
[ GHC User's Guide ]
[varid| |]
: Template Haskell’s quasi-quotation syntax
[ GHC User's Guide ]
greet name = [interpolate | Hello, #name! |]
[|| ||]
: Typed Template Haskell’s quotation syntax
[ GHC User's Guide ]
_
: "wildcard pattern"
[ Haskell 2010 Language Report ]
_
: unused identifiers beginning with underscore
[ GHC User's Guide ]
[ Haskell 2010 Language Report ]
_w = True -- No warning: _w starts with an underscore
_
: "typed hole" (expression level)
[ GHC User's Guide ]
_
: "type wildcard" (type level)
[ GHC User's Guide ]
请发表评论