summaryrefslogtreecommitdiff
path: root/contrib/haskell/src/Hkl/PyFAI/Calib.hs
blob: 1c41a09b26a1e2bbc0ae2965b56fcf5ec2d768d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE UnicodeSyntax #-}

module Hkl.PyFAI.Calib
       ( ToPyFAICalibArg(..) ) where

import Data.Text (unpack)
import Numeric.Units.Dimensional.Prelude ((/~), nano, meter)

import Hkl.Types ( WaveLength )
import Hkl.Detector ( Detector )
import Hkl.PyFAI.Calibrant ( Calibrant )
import Hkl.PyFAI.Detector ( toPyFAI )

class ToPyFAICalibArg a where
  toPyFAICalibArg  a  String

instance ToPyFAICalibArg FilePath where
  toPyFAICalibArg f = f

instance ToPyFAICalibArg (Detector a) where
  toPyFAICalibArg d = "-D" ++ unpack (toPyFAI d)

instance ToPyFAICalibArg Calibrant where
  toPyFAICalibArg c = "-c " ++ show c

instance ToPyFAICalibArg WaveLength where
    toPyFAICalibArg w = "-w " ++ show ((w /~ nano meter) * 10)