Hoogle Search
Within LTS Haskell 24.3 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
head :: Storable a => Vector a -> astorablevector Data.StorableVector O(1) Extract the first element of a Vector, which must be non-empty. It is a checked error to pass an empty Vector.
-
Cabal-syntax Distribution.Compat.Prelude Extract the first element of the stream.
head :: HasCallStack => OsString -> OsCharos-string System.OsString O(1) Extract the first element of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString. This is a partial function, consider using uncons instead.
head :: HasCallStack => ShortByteString -> Word8os-string System.OsString.Data.ByteString.Short O(1) Extract the first element of a ShortByteString, which must be non-empty. An exception will be thrown in the case of an empty ShortByteString. This is a partial function, consider using uncons instead.
head :: HasCallStack => ShortByteString -> Word16os-string System.OsString.Data.ByteString.Short.Word16 O(1) Extract the first element of a ShortByteString, which must be at least one Word16. An exception will be thrown in the case of an empty ShortByteString.
head :: HasCallStack => OsString -> OsCharos-string System.OsString.Internal O(1) Extract the first element of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString. This is a partial function, consider using uncons instead.
head :: HasCallStack => PosixString -> PosixCharos-string System.OsString.Posix O(1) Extract the first element of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString. This is a partial function, consider using uncons instead.
head :: HasCallStack => WindowsString -> WindowsCharos-string System.OsString.Windows O(1) Extract the first element of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString. This is a partial function, consider using uncons instead.
head :: IsNonEmpty f a a "head" => f a -> arelude Relude.List.NonEmpty O(1). Extracts the first element of a NonEmpty list. Actual type of this function is the following:
head :: NonEmpty a -> a
but it was given a more complex type to provide friendlier compile time errors.>>> head ('a' :| "bcde") 'a' >>> head [0..5 :: Int] ... ... 'head' works with 'NonEmpty', not ordinary lists. Possible fix: Replace: [Int] With: NonEmpty Int ... However, you can use 'head' with the ordinary lists. Apply 'viaNonEmpty' function from relude: viaNonEmpty head (yourList) Note, that this will return 'Maybe Int' therefore it is a safe function unlike 'head' from the standard Prelude ... >>> head (Just 'a') ... ... 'head' works with 'NonEmpty Char' lists But given: Maybe Char ...
head :: HasCallStack => [a] -> arelude Relude.Unsafe Extract the first element of a list, which must be non-empty. To disable the warning about partiality put {-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-} at the top of the file. To disable it throughout a package put the same options into ghc-options section of Cabal file. To disable it in GHCi put :set -Wno-x-partial -Wno-unrecognised-warning-flags into ~/.ghci config file. See also the migration guide.
Examples
>>> head [1, 2, 3] 1
>>> head [1..] 1
>>> head [] *** Exception: Prelude.head: empty list