简体   繁体   中英

Composed data type haskell

So, I have this function:

solve x y = do
            ...
            return (newx,y++[1])

where x and newx are [[Int]] and y is [Int]. And with this function, I will return a "value". Now, I would like to know how can I "process" this value in order to extract the 2 components and use them separately.

Something like this:

a <- solve x y
b <- a[0]
c <- a[1]

as the return will wrap it into some monad, you can then get to the parts by deconstructing it directly inside a do block like this:

do
    (b,c) <- solve x y

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