-- Some basic types

module BaseTypes (module BaseTypes,maybeDo,updIORef) where
import Utils (maybeDo,updIORef)

import Int  (int32ToInt, Int32)
import List (find)
import IOExts
import Compatibility

type RealVal  = Double
type Length   = RealVal
type Radians  = RealVal
type Fraction = RealVal  -- 0 to 1 (inclusive)

type Time = Double
type DTime = Time                       -- Time deltas, i.e., durations

-- Times that stand for +/- infinity.
maxTime = 1.0e30 :: Time
minTime = -maxTime

-- For scaling polynomials and vectors.  We should really be using binary
-- type relations, rather than having Double hardwired.

type Scalar = Double

-- For lifting and sections
pair x y = (x,y)

cond a b c = if a then b else c

-- From Int32 to Int

fromInt32 :: Num a => Int32 -> a
fromInt32 = fromInt . int32ToInt

-- Isn't this somewhere standard??
assoc :: Eq key => [(key,a)] -> key -> Maybe a
-- assoc pairs key = map snd (find ((== key) . fst) pairs)
assoc = flip lookup

debugMsg :: Show a => a -> IO ()
debugMsg s = return ()
