1

I see the <$> notation often in the Plutus/Haskell code but have no idea what it means. I understand that $ alone is a parenthesis replacement. Is <$> similar? Does it suggest enclosing parenthesis?

Example from the deploy.hs script in week 3.

dataToScriptData :: Data -> ScriptData
dataToScriptData (Constr n xs) = ScriptDataConstructor n $ dataToScriptData  xs
dataToScriptData (Map xs)      = ScriptDataMap [(dataToScriptData x, dataToScriptData y) | (x, y)  xs
dataToScriptData (I n)         = ScriptDataNumber n
dataToScriptData (B bs)        = ScriptDataBytes bs

So hard to do a Google search on Haskell's cryptic syntax!

2 Answers 2

5

It's a functor map which is essentially an fmap function for the functor class. This might be of some use: https://www.fpcomplete.com/haskell/tutorial/operators/

1
3

For Haskell questions of this sort Hoogle is the ultimate resource.

For operators like <$> you need to enclose them in parenthesis eg (<$>).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.