Module

Data.Pointed.Convert

Package
purescript-pointed
Repository
vladciobanu/purescript-pointed

This module defines conversion functions between Can, Smash, and Wedge.

The examples assume that the pointed modules are imported qualified:

import Data.Pointed.Can as C
import Data.Pointed.Smash as S
import Data.Pointed.Wedge as W

#canSmash Source

canSmash :: forall b a. Can a b -> Smash a b

Convert from Can to Wedge.

> canSmash (C.Non :: Can String Int)
S.Non

> canSmash (C.One "hello" :: Can String Int)
S.Non

> canSmash (C.Eno 42 :: Can String Int)
S.Non

> canSmash (C.Two "hello" 42 :: Can String Int)
S.Two "hello" 42

#smashCan Source

smashCan :: forall b a. Smash a b -> Can a b

Convert from Wedge to Can.

> smashCan (S.Non :: Smash String Int)
C.Non

> smashCan (S.Two "hello" 42 :: Smash String Int)
C.Two "hello" 42

#canWedge Source

canWedge :: forall b a. Can a b -> Wedge a b

Convert from Can to Wedge.

> canWedge (C.Non :: Can String Int)
W.Non

> canWedge (C.One "hello" :: Can String Int)
W.One "hello"

> canWedge (C.Eno 42 :: Can String Int)
W.Eno 42

> canWedge (C.Two "hello" 42 :: Can String Int)
W.Non

#wedgeCan Source

wedgeCan :: forall b a. Wedge a b -> Can a b

Convert from Wedge to Can.

> wedgeCan (W.Non :: Wedge String Int)
C.Non

> wedgeCan (W.One "hello" :: Wedge String Int)
C.One "hello"

> wedgeCan (W.Eno 42 :: Wedge String Int)
C.Eno 42

#hulkSmash Source

hulkSmash :: forall b a. a -> b -> Wedge a b -> Smash a b

Convert from Wedge to Smash, given default values for a and b.

> hulkSmash "world" 1 (W.Non :: Wedge String Int)
S.Non

> hulkSmash "world" 1 (W.One "hello" :: Wedge String Int)
S.Two "hello" 1

> hulkSmash "world" 1 (W.Eno 42 :: Wedge String Int)
C.Eno "world" 42