Haskell: Check if integer, or check type of variable

前端 未结 2 1011
死守一世寂寞
死守一世寂寞 2020-12-05 15:28

So let\'s say you have a variable n.

You want to check if its an integer, or even better yet check what type it is.

I know there is a function in haskell

2条回答
  •  Happy的楠姐
    2020-12-05 15:59

    If you are using an interactive Haskell prompt (like GHCi) you can type :t and that will give you the type of an expression.

    e.g.

    Prelude> :t 9
    

    gives

    9 :: (Num t) => t
    

    or e.g.

    Prelude> :t (+)
    

    gives

    (+) :: (Num a) => a -> a -> a
    

提交回复
热议问题