55c1a35d210bc3e60a8a065185b07aa184cd5766
[ghc.git] / testsuite / tests / stranal / sigs / T8598.hs
1 {-# OPTIONS_GHC -fplugin StrAnalAnnotation #-}
2 {-# LANGUAGE MagicHash , UnboxedTuples #-}
3
4 module T8598(fun) where
5
6 import GHC.Float (Double(..))
7 import GHC.Integer (decodeDoubleInteger, encodeDoubleInteger)
8 import StrAnalAnnotation (StrAnal(StrAnal))
9
10 -- Float.scaleFloat for Doubles, slightly simplified
11 fun :: Double -> Double
12 fun x | isFix = x
13 | otherwise = case x of
14 (D# x#) -> case decodeDoubleInteger x# of
15 (# i, j #) -> D# (encodeDoubleInteger i j)
16 where
17 isFix = isDoubleFinite x == 0
18 {-# ANN fun (StrAnal "<S(S),1*U(U)>m") #-}
19
20 foreign import ccall unsafe "isDoubleFinite" isDoubleFinite :: Double -> Int