| Copyright | (c) Stanford University 2015 |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | ezyang@cs.stanford.edu |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.NF
Description
This module provides a data type, NF, representing data which has
been evaluated to "Normal Form". This is a useful type discipline
for many situations when normal form data is necessary, e.g. when
transmitting data to other threads over channels. If a library
that you are using has the following type:
strictWriteChan ::NFDataa =>Chana -> a ->IO()
you can specialize it to the following type in order to avoid the
cost of repeatedly deepseqing a value when it is not necessary:
strictWriteChan_ ::Chan(NFa) ->NFa ->IO() strictWriteChan_ = strictWriteChan
You should also consider providing APIs which only accept NF
values, to prevent users from accidentally deepseqing.