Skip to content

Commit 5a39f20

Browse files
committed
tutorial: Example for serializable data.
1 parent 244a951 commit 5a39f20

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: tutorials/1ch.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,19 @@ instance (Binary a, Typeable a) => Serializable a
168168

169169
That is, any type that is `Binary` and `Typeable` is `Serializable`. This is
170170
the case for most of Cloud Haskell's primitive types as well as many standard
171-
data types.
171+
data types. For custom data types, the `Typeable` instance is always
172+
given by the compiler, and the `Binary` instance can be auto-generated
173+
too in most cases, e.g.:
174+
175+
{% highlight haskell %}
176+
{-# LANGUAGE DeriveDataTypeable #-}
177+
{-# LANGUAGE DeriveGeneric #-}
178+
179+
data T = T Int Char deriving (Generic, Typeable)
180+
181+
instance Binary T
182+
{% endhighlight %}
183+
172184

173185
### Spawning Remote Processes
174186

0 commit comments

Comments
 (0)