简体   繁体   中英

Purescript Import infix type constrctor

Here, \/ is from Data.Either .

This example is copied from the link above:

f :: (Int \/ String \/ Boolean) -> String
f = show \/ identity \/ if _ then "Yes" else "No"

What does the import statement look like?

Here you need to import both the type \/ and the value \/ .

The syntax for importing type operators is type (\/) . The prefix type is necessary for disambiguation - that is, to let the compiler know that you're importing the type, not the value that might have the same name.

And the syntax for importing the value is as usual.

So the whole import would look like this:

import Data.Either.Nested (type (\/), (\/))

In conclusion, I would recommend using your IDE integration (for example, here's a VSCode extension ) to insert imports for you. That way you don't have to know the precise syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM