Hex to ASCII conversion in Haskell
Calling error is fine for a small program like this.

For more advanced error handling see the Failure page on HaskellWiki.



Some comments about your code:

unhex (x:[]) = error "invalid input length"


x is not used here, use this pattern instead: (_:[])

unhex (x:y:xs) = [(shiftL (hex2val x) 4) .|. (hex2val y)] ++ unhex xs


[x] ++ xs is usually written x : xs

hex2val' $ (x .|. 0x20)


$ is useless here.