You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- | Extract the first element of a list, which must be non-empty.
head :: HasCallStack => [a] -> a
head = \case
[] -> error "..."
x : _ -> x
Motivation: Universum is primarily designed to be used in business logic, if someone needs advanced and lightweight manipulation with lists, he better import Data.List or some library with special data structures as Universum provides far not all possible useful functions anyway.
Pros:
Easer to debug.
Cons:
Error messages will differ.
Slightly less performant (carrying call stack has its costs, some rewrite rules will probably get lost).
Attempt to import head both from our Unsafe module and Data.List module simultaneously will now fail, though this is minor as Unsafe module should be imported qualified.
The text was updated successfully, but these errors were encountered:
Problem: functions from `Universum.Unsafe` don't carry `CallStack`.
Sometimes it is hard to debug when you don't have stack trace.
Solution: attached `CallStack` to all functions from `Universum.Unsafe`
by copying them from `base` and replacing `errorWithoutStackTrace` with
`error` function.
For instance, have
Motivation:
Universum
is primarily designed to be used in business logic, if someone needs advanced and lightweight manipulation with lists, he better importData.List
or some library with special data structures asUniversum
provides far not all possible useful functions anyway.Pros:
Cons:
head
both from ourUnsafe
module andData.List
module simultaneously will now fail, though this is minor asUnsafe
module should be imported qualified.The text was updated successfully, but these errors were encountered: