Haskell - Return item from custom type -


i'm working on haskell problem class, , can't seem syntax right pulling item out of custom type. here's type:

-- finite state machine m = (q, q0, f, d)  type fsm = ([int], int, [int], [(int,char,int)]) 

and here's test value i've been working with:

testfsm :: fsm  testfsm = ( [ 1, 2, 3 ], 1, [ 3 ], [ ( 1, 'a', 2 ), ( 2, 'b', 3 ), ( 1, 'b', 1 ) ] ) 

i want able pull out each piece of data fsm type, i'm not quite sure on how that. have tried this:

fsmgetq fsm = [ q | ( q, q0, f, d ) <- fsm ] 

but if run function testfsm get:

<interactive>:102:9:     couldn't match type `([int], int, [int], [(int, char, int)])'                   `[(t0, t10, t20, t30)]'     expected type: [(t0, t10, t20, t30)]       actual type: fsm     in first argument of `fsmgetq', namely `testfsm'     in expression: fsmgetq testfsm     in equation `it': = fsmgetq testfsm 

i've got lot of helper functions working individual elements, can't figure out how extract them type fsm.

you can extract this:

fsmgetq (q, _, _, _) = q 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -