Skip to content

Port coerce example from unsafe-coerce to this repo #4

@JordanMartinez

Description

@JordanMartinez

In purescript/purescript-unsafe-coerce#11, we removed the below documentation because that should go here now. This is a reminder to add that to this repo.

-- | One application for this function is to avoid doing work that you know is a
-- | no-op because of newtypes. For example, if you have an `Array (Conj a)` and you
-- | want an `Array (Disj a)`, you could do `Data.Array.map (runConj >>> Disj)`, but
-- | this performs an unnecessary traversal. `coerce` accomplishes the same
-- | for free.
-- |
-- | It is highly recommended to define specializations of this function rather than
-- | using it as-is. For example:
-- |
-- | ```purescript
-- | mapConjToDisj :: forall a. Array (Conj a) -> Array (Disj a)
-- | mapConjToDisj = coerce
-- | ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions