i have a line of code which doesn’t work as i expect it too:
parentspermission x y = if x && y == False then print(“no”) else print (“yes”)
when i run parentspermission False False in ghci it gives me “yes” instead of “no” as it should be when false && false is false
this may not be worth mentioning but i am a beginner to haskell ive had some experience in python before and i am against using ai to learn haskell, i want to do it the old school way
a little addition is that when i ran parentspermission True False i got “no” as expected but when i ran parentspermission False True i somehow got “yes”
my understanding of this is the order i place && and ==, i would have usually placed a singlar equal sign after x && y but this isnt possible as a single equal sign is used to define functions.
Noting that you are new to Haskell, you do not need ( ) around the "no" and "yes" values. To apply a function f :: a -> b to x :: a, you write f x. Accordingly, you can write print "no".
Also, here, if you want Haskell code to be presented nicely, you can put it between ‘fences’ (each on their own lines) before and after the code ~~~haskell (opening fence) and ~~~ (closing fence). For example:
parentspermission :: Bool -> Bool -> IO ()
parentspermission x y = if (x && y) == False then print “no” else print “yes”
A second also: print "no" is equivalent to putStrLn (show "no"). As "no" is a String, it may be that you do not actually want to output show "no" but simply "no". That is because:
> show "no" == "\"no\""
True
(where \" is an escaped double quote character in a Haskell string).
A thing i would like to add although this may be a late response is that i started learning haskell via the learn you haskell for a great good website, but recently ive started reading real world haskell published by oreilly and i can say it is much better as it goes into much more depth
You either purchase the book or use the ebook which is what im doing, i think this is an early version no one was supposed to get hands on but ive got it, just search up real world haskell in goole chrome and a link by red bean software will have a pdf called rwhdraft