Skip to content

Small bugs in the haskell code snippets #4

@saeednj

Description

@saeednj

In the "Single Digit Math" Chapter:

  1. Section "A Single Digit" (first code snippet):
    module Data.Char should be replaced with
    import Data.Char.
  2. Section "Adding Types":
    The data type has a terminal type Num Int, but it is instantiated with a Char in isDigit x = Num x.
    Either change the Num Int to Num Char or construct it with the ordinal value of the character: isDigit x = Num ((ord x)-(ord '0'))

Maybe not that important in general, but for someone not proficient in haskell like me, it took a while to find why the codes are not compiling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions