Skip to content

Commit

Permalink
Haskell wrapper for date field test
Browse files Browse the repository at this point in the history
  • Loading branch information
olorin committed Jul 18, 2016
1 parent ecdbf8e commit e5deeaa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Warden/Parser/Field.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

module Warden.Parser.Field (
checkFieldBool
, checkFieldDate
, checkFieldNumeric
, integralFieldP
, realFieldP
Expand Down Expand Up @@ -78,3 +79,15 @@ numericFieldP = {-# SCC numericFieldP #-}
, (NumericField . fromIntegral) <$> integralFieldP
]
{-# INLINE numericFieldP #-}

checkFieldDate :: ByteString -> Bool
checkFieldDate bs = {-# SCC checkFieldDate #-}
unsafePerformIO $ do
BSU.unsafeUseAsCStringLen bs $ \(bsPtr, bsLen) ->
cBool <$> warden_field_datetime (castPtr bsPtr) (fromIntegral bsLen)
{-# INLINE checkFieldDate #-}

foreign import ccall unsafe warden_field_datetime
:: Ptr Word8
-> CSize
-> IO Word8

0 comments on commit e5deeaa

Please sign in to comment.