Purescript coding standard
newtype
instead of type
where possible
type
is a type synonym, which is a weak form of newtype
newtype
is a strong form of type
that allows for more type safetynewtype
over data
for single-variant types
data
is designed for multi-variant typesdata
introduces a runtime overhead of boxing and unboxingdo
only in monadic context, use where
or let
otherwise
do
in non-monadic context is misleading and confusingstate
st
const x
\_ -> x
(_ + 1)
\x -> x + 1
f g
f (\value -> g value)
import Foo.Bar as Foo.Bar
import Foo.Bar
, because it pollutes the namespace with all symbols exported by Foo.Bar
Prelude
is implicitly imported, so it is not necessary to qualify its symbolsimport Foo.Bar (baz)
, because it pollutes the namespace with baz
, which still may not be universally uniqueimport Foo.Bar as FB
, because it introduces cognitive overhead on the reader
Foo.Bar.baz
baz
Bar.baz
FB.baz