From dfeee5d4a727bacdcbf4f6b2da608c61ff682765 Mon Sep 17 00:00:00 2001 From: Serhii Khoma Date: Wed, 3 Jun 2020 15:07:58 +0300 Subject: [PATCH] fix function -> add example --- src/Control/Lazy.purs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Control/Lazy.purs b/src/Control/Lazy.purs index 3434d09..6b736a5 100644 --- a/src/Control/Lazy.purs +++ b/src/Control/Lazy.purs @@ -19,6 +19,17 @@ instance lazyUnit :: Lazy Unit where -- | `fix` defines a value as the fixed point of a function. -- | -- | The `Lazy` instance allows us to generate the result lazily. +-- | +-- | Example: +-- | ```purs +-- | fib :: Int -> Int +-- | fib = fix go +-- | where +-- | go :: (Int -> Int) -> Int -> Int +-- | go _ 0 = 0 +-- | go _ 1 = 1 +-- | go f n = f (n - 1) + f (n - 2) +-- | ``` fix :: forall l. Lazy l => (l -> l) -> l fix f = go where