{-# OPTIONS_GHC -funbox-strict-fields #-} {-# LANGUAGE NoImplicitPrelude, BangPatterns #-} module Phladiprelio.General.Datatype where import GHC.Base import GHC.List import Data.Char (isDigit) import Text.Read import GHC.Num ((*)) data Phladiprelio t a b = Phl { inputData :: t a, convF :: t a -> t b } data BasicUkr = U1 {-# UNPACK #-} !Char | U2 !Double deriving (Eq, Ord) readBasicUkr0 :: Double -> (String -> [a]) -> ([a] -> [Double]) -> String -> [Double] readBasicUkr0 temp fConvA fConvD xs@(_:_) = dc `mappend` ((readU2 ws * d) : readBasicUkr0 d fConvA fConvD qs) where (ts, us) = break (== '_') xs dc | null ts = [temp] | otherwise = fConvD . fConvA $ ts d = last dc vs = dropWhile (== '_') us (ws, qs) = span isDigit vs readBasicUkr0 _ _ _ _ = [] readBasicUkr = readBasicUkr0 1.0 {-# INLINE readBasicUkr #-} readU2 :: String -> Double readU2 xs@(y:ys) = read (y:'.':ys)::Double