Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why not?

Name: Anonymous 2011-10-06 13:28


$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> let yoba a b = if a < b then 123 else "abc"

<interactive>:1:29:
    No instance for (Num [Char])
      arising from the literal `123' at <interactive>:1:29-31
    Possible fix: add an instance declaration for (Num [Char])
    In the expression: if a < b then 123 else "abc"
    In the definition of `yoba':
        yoba a b = if a < b then 123 else "abc"
Prelude>

Name: Anonymous 2011-10-07 1:53

>>22
It doesn't work

$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> let yoba a b = if a < b then Left 123 else Right "abc"
Prelude> (yoba 3 4)
Left 123
Prelude> (yoba 3 4)/2

<interactive>:1:0:
    No instance for (Fractional (Either t [Char]))
      arising from a use of `/' at <interactive>:1:0-11
    Possible fix:
      add an instance declaration for (Fractional (Either t [Char]))
    In the expression: (yoba 3 4) / 2
    In the definition of `it': it = (yoba 3 4) / 2
Prelude>

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List