UPDATE:
To be fair, my example was a simplification of a problem I'm facing, I've tried implementing the solution, but it doesn't seem to work...
followConnection :: Connection->Crib->Stecker->Offsets->Maybe Stecker
followConnection w x y z
| steckerAdd ((enigmaEncode (getSndTripleEl w) (SimpleEnigma rotor1 rotor2 rotor3 reflectorB) (calculateOffset z (getFirstTripleEl w))), (getThirdTripleEl w)) y == Nothing = Nothing
| steckerAdd ((enigmaEncode (getSndTripleEl w) (SimpleEnigma rotor1 rotor2 rotor3 reflectorB) (calculateOffset z (getFirstTripleEl w))), (getThirdTripleEl w)) y == Just (y) = y
With
steckerAdd ((enigmaEncode (getSndTripleEl w) (SimpleEnigma rotor1 rotor2 rotor3 reflectorB) (calculateOffset z (getFirstTripleEl w))), (getThirdTripleEl w)) y == Just (y) = y
Giving
Couldn't match type [(Char, Char)]' with
Maybe Stecker'
Expected type: Maybe Stecker
Actual type: Stecker
I have a function (myFunction) which returns "Maybe Int" as an output
I would like to code something similar to:
myOtherFunction :: Int -> Maybe Int
myOtherFunction x
| myFunction x == Nothing = 1
| myFunction x == 1 = 2
| otherwise = 3
However, Haskell doesn't seem to like me comparing a "Maybe Int" value to an int...
I also tried "casting" it to an Int by making it:
| fromMaybe(myFunction) x == 1 = 2
Where the function is:
fromMaybe :: Maybe a -> a
fromMaybe (Just x)=x
Ideas?
myFunction x == Just 1
? – user824425