ghci> :t map -- Typ anzeigen
map :: (a -> b) -> [a] -> [b]
ghci> :i Maybe -- Informationen zu einem Namen
ghci> :l Datei.hs -- laden
ghci> :r -- neu laden
ghci> :k Maybe -- Kind (Typ von Typen)
ghci> :q
Hoogle: Suche nach der Typsignatur, z. B. [a] -> Int findet length.
Häufig genutzte Erweiterungen
text
{-# LANGUAGE OverloadedStrings #-} -- String-Literale als Text
{-# LANGUAGE LambdaCase #-} -- \case Muster
{-# LANGUAGE TupleSections #-} -- (,x)
{-# LANGUAGE ScopedTypeVariables #-} -- Typannotationen in Mustern
{-# LANGUAGE RecordWildCards #-} -- Person{..}
{-# LANGUAGE DeriveFunctor #-} -- deriving Functor
haskell
{-# LANGUAGE LambdaCase, TupleSections, RecordWildCards #-}data Konfig = Konfig { host :: String, port :: Int }
beschreibe :: Konfig -> String
beschreibe Konfig {..} = host ++ ":" ++ show port
status :: Int -> String
status = \case200 -> "OK"404 -> "Nicht gefunden"
_ -> "anderes"main :: IO ()
main = doputStrLn (beschreibe (Konfig "localhost"8080))
print (map status [200, 404, 500])
print (map (,True) [1, 2])