Copyright | (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2020 Kowainik |
---|---|

License | MIT |

Maintainer | Kowainik <xrom.xkov@gmail.com> |

Stability | Stable |

Portability | Portable |

Safe Haskell | Unsafe |

Language | Haskell2010 |

- Unsafe list functions
- Unsafe
`Maybe`

functions - Unsafe Text.Read functions

**⚠️ Warning ⚠️**

This module contains unsafe partial functions. They are unavoidable sometimes, but we encourage you to use safer analogues:

Partial | Total |
---|---|

| |

| |

| |

| |

This module is intended to be imported qualified and it is not included in default prelude exports.

import qualifiedRelude.Unsafe as Unsafe foo :: [a] -> a foo = Unsafe.`head`

# Unsafe list functions

*O(n)*. Return all the elements of a list except the last one.
The list must be non-empty.

(!!) :: [a] -> Int -> a infixl 9 #

List index (subscript) operator, starting from 0.
It is an instance of the more general `genericIndex`

,
which takes an index of any integral type.

at :: Int -> [a] -> a Source #

Similar to `!!`

but with flipped arguments.
get element from list using index value starting from `0`.

`>>>`

"c"`at 2 ["a", "b", "c"]`

it is also useful when used in a partially applied position like:

`>>>`

["b","b","b"]`map (at 1) [["a","b","c"], ["a","b","c"], ["a","b","c"]]`

# Unsafe

`Maybe`

functions

fromJust :: HasCallStack => Maybe a -> a #

# Unsafe Text.Read functions

read :: Read a => String -> a #

The `read`

function reads input from a string, which must be
completely consumed by the input process. `read`

fails with an `error`

if the
parse is unsuccessful, and it is therefore discouraged from being used in
real applications. Use `readMaybe`

or `readEither`

for safe alternatives.

`>>>`

123`read "123" :: Int`

`>>>`

*** Exception: Prelude.read: no parse`read "hello" :: Int`