Skip to content

deferFunctor - helper for defining defer #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Control/Lazy.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Control.Lazy where

import Data.Unit (Unit)
import Prelude

-- | The `Lazy` class represents types which allow evaluation of values
-- | to be _deferred_.
Expand All @@ -10,6 +10,10 @@ import Data.Unit (Unit)
class Lazy l where
defer :: (Unit -> l) -> l

-- | `deferFunctor` can be used to define a trivial `defer` for any Functor
deferFunctor :: forall l a. Functor l => Lazy a => (Unit -> l a) -> l a
deferFunctor f = ((map (defer <<< const)) <$> f) unit

-- | `fix` defines a value as the fixed point of a function.
-- |
-- | The `Lazy` instance allows us to generate the result lazily.
Expand Down