Commit 77a4675a authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Update the docs on how you bind unlifted types in let/where clauses

parent 8bf9fcc6
...@@ -210,22 +210,20 @@ in a <emphasis>top-level</emphasis> binding. ...@@ -210,22 +210,20 @@ in a <emphasis>top-level</emphasis> binding.
in a <emphasis>recursive</emphasis> binding. in a <emphasis>recursive</emphasis> binding.
</para></listitem> </para></listitem>
<listitem><para> You may bind unboxed variables in a (non-recursive, <listitem><para> You may bind unboxed variables in a (non-recursive,
non-top-level) pattern binding, but any such variable causes the entire non-top-level) pattern binding, but you must make any such pattern-match
pattern-match strict. For example, rather than:
to become strict. For example:
<programlisting> <programlisting>
data Foo = Foo Int Int# data Foo = Foo Int Int#
f x = let (Foo a b, w) = ..rhs.. in ..body.. f x = let (Foo a b, w) = ..rhs.. in ..body..
</programlisting> </programlisting>
Since <literal>b</literal> has type <literal>Int#</literal>, the entire pattern you must write:
match
is strict, and the program behaves as if you had written
<programlisting> <programlisting>
data Foo = Foo Int Int# data Foo = Foo Int Int#
f x = case ..rhs.. of { (Foo a b, w) -> ..body.. } f x = let !(Foo a b, w) = ..rhs.. in ..body..
</programlisting> </programlisting>
since <literal>b</literal> has type <literal>Int#</literal>.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment