Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Potential Hoogle input format for PureScript
@name purescript-maybe
@version 0.2.2
module Data.Maybe where
-- | <p>The <code>Maybe</code> type is used to represent optional values and can be seen as
-- | something like a type-safe <code>null</code>, where <code>Nothing</code> is <code>null</code> and <code>Just x</code>
-- | is the non-null value <code>x</code>.</p>
data Maybe a
Just :: forall a. a -> Maybe a
Nothing :: forall a. Maybe a
-- | <p>Takes a default value, a function, and a <code>Maybe</code> value. If the <code>Maybe</code>
-- | value is <code>Nothing</code> the default value is returned, otherwise the function
-- | is applied to the value inside the <code>Just</code> and the result is returned.</p>
-- | <pre class="purescript"><code>maybe x f Nothing == x
-- | maybe x f (Just y) == f y
-- | </code></pre>
maybe :: forall a b. b -> (a -> b) -> (Maybe a) -> b
-- | <p>Takes a default value, and a <code>Maybe</code> value. If the <code>Maybe</code> value is
-- | <code>Nothing</code> the default value is returned, otherwise the value inside the
-- | <code>Just</code> is returned.</p>
-- | <pre class="purescript"><code>fromMaybe x Nothing == x
-- | fromMaybe x (Just y) == y
-- | </code></pre>
fromMaybe :: forall a. a -> (Maybe a) -> a
-- | <p>Returns <code>true</code> when the <code>Maybe</code> value was constructed with <code>Just</code>.</p>
isJust :: forall a. (Maybe a) -> Boolean
-- | <p>Returns <code>true</code> when the <code>Maybe</code> value is <code>Nothing</code>.</p>
isNothing :: forall a. (Maybe a) -> Boolean
module Data.Maybe.Unsafe where
-- | <p>A partial function that extracts the value from the <code>Just</code> data
-- | constructor. Passing <code>Nothing</code> to <code>fromJust</code> will throw an error at
-- | runtime.</p>
fromJust :: forall a. (Data.Maybe.Maybe a) -> a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.