concept maybe type in category haskell
appears as: Maybe type, Maybe types, Maybe type

This is an excerpt from Manning's book Get Programming with Haskell.
In this lesson, our objective was to introduce you to one of Haskell’s more interesting parameterized types: Maybe. The Maybe type allows you to model values that may be missing. Maybe achieves this by using two data constructors, Just and Nothing. Values represented by the Nothing data constructor are missing. Values represented by the Just a constructor can be safely accessed through pattern matching. Maybe is a great example of how powerful types make your code less erro- prone. Because of the Maybe type, the entire class of errors related to having null values is completely eliminated. Let’s see if you got this.
Listing 26.1. The necessary imports for marc_to_html.hs
{-# LANGUAGE OverloadedStrings #-} #1 import qualified Data.ByteString as B #2 import qualified Data.Text as T #3 import qualified Data.Text.IO as TIO #4 import qualified Data.Text.Encoding as E #5 import Data.Maybe #6 #1 Your OverloadStrings LANGUAGE pragma so you can use string literals for all string types #2 Because you’re working with binary data, you need a way to manipulate bytes. #3 Anytime you’re working with text, especially Unicode, you need the Text type. #4 The IO functions for Text are imported separately. #5 Part of working with Unicode is safely encoding and decoding it to and from binary data. #6 You’ll be using Maybe types, as the isJust function from the Maybe package is useful. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":56},{\"line\":0,\"ch\":58}],[{\"line\":7,\"ch\":0},{\"line\":7,\"ch\":2}],[{\"line\":1,\"ch\":56},{\"line\":1,\"ch\":58}],[{\"line\":8,\"ch\":0},{\"line\":8,\"ch\":2}],[{\"line\":2,\"ch\":56},{\"line\":2,\"ch\":58}],[{\"line\":9,\"ch\":0},{\"line\":9,\"ch\":2}],[{\"line\":3,\"ch\":56},{\"line\":3,\"ch\":58}],[{\"line\":10,\"ch\":0},{\"line\":10,\"ch\":2}],[{\"line\":4,\"ch\":56},{\"line\":4,\"ch\":58}],[{\"line\":11,\"ch\":0},{\"line\":11,\"ch\":2}],[{\"line\":5,\"ch\":56},{\"line\":5,\"ch\":58}],[{\"line\":12,\"ch\":0},{\"line\":12,\"ch\":2}]]"} !@%STYLE%@!