Top-level strict or unlifted binds not allowed [GHC-48099]
In Haskell, top-level bindings must be represented by thunks because the evaluation time of things that can fail is hard to understand when they’re part of a module. This rules out strict bindings as well as unlifted bindings.
Examples
Top-level strict bindings
Message
Strict.hs:3:1: error: [GHC-48099]
Top-level strict bindings aren't allowed: !x = 5
|
3 | !x = 5
| ^^^^^^
Explanation
The top-level binding of x
is a strict pattern, which is not allowed. This can be fixed by not having a strict pattern for a top-level binding.
Strict.hs
Before
module Strict where
!x = 5
After
module Strict where
x = 5
Unlifted top-level binding
Message
Unlifted.hs:4:1: error: [GHC-48099]
Top-level bindings for unlifted types aren't allowed: x = 4#
|
4 | x = 4#
| ^^^^^^
Explanation
Top-level bindings are not allowed to be unlifted types, because they always need to be a thunk. To fix the issue, use a lifted type.
Unlifted.hs
Before
{-# LANGUAGE MagicHash #-}
module Unlifted where
x = 4#
After
module Unlifted where
x = 4