I am new to Haskell and I am using the llvm-general-ure-3.5.1.0 library:
https://hackage.haskell.org/package/llvm-general-pure-3.5.1.0/docs/
There is a basic block data type, Named and name data type:
data BasicBlock = BasicBlock Name [Named Instruction] (Named Terminator)
deriving (Eq, Read, Show, Typeable, Data)
data Named a
= Name := a
| Do a
data Name
= Name String -- ^ a string name
| UnName Word -- ^ a number for a nameless thing
The problem I am having is pattern matching against Named Instruction.
My code looks like this:
executeInstruction :: Named Instruction -> Memory -> Memory
executeInstruction inst mem =
case inst of
Add nsw nuw op0 op1 meta -> undefined
This gives me an error message that I expect, my types don't match of Named Instruction vs Instruction.
So I want to strip off the Named and have just an Instruction left.
stripN :: Named Instruction -> Instruction
stripN (Name n inst) = inst
This gives this error:
Constructor `Name' should have 1 argument, but has been given 2 In the pattern: Name n inst
I understand the error. But I don't see how to get just an Instruction from a Named Instruction.
Thanks,