Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate dependence on data-binary-ieee754 #414

Closed
yurivict opened this issue Jul 21, 2018 · 5 comments
Closed

Deprecate dependence on data-binary-ieee754 #414

yurivict opened this issue Jul 21, 2018 · 5 comments

Comments

@yurivict
Copy link

It says on its author's website https://john-millikin.com/software that data-binary-ieee754 is obsolete and cereal should be preferred.

@LeventErkok
Copy link
Owner

Looks like this is all the code we need from that library:

module CastFloatsToWords(floatToWord, wordToFloat, doubleToWord, wordToDouble) where

import Data.Word
import qualified Foreign as F
import System.IO.Unsafe (unsafePerformIO)

floatToWord :: Float -> Word32
floatToWord = fromFloat

wordToFloat :: Word32 -> Float
wordToFloat = toFloat

doubleToWord :: Double -> Word64
doubleToWord = fromFloat

wordToDouble :: Word64 -> Double
wordToDouble = toFloat

toFloat :: (F.Storable word, F.Storable float) => word -> float
toFloat word = unsafePerformIO $ F.alloca $ \buf -> do
        F.poke (F.castPtr buf) word
        F.peek buf

fromFloat :: (F.Storable word, F.Storable float) => float -> word
fromFloat float = unsafePerformIO $ F.alloca $ \buf -> do
        F.poke (F.castPtr buf) float
        F.peek buf

I'm not sure if cereal exposes these functions.

We can easily "steal" this and put it into a utility function and get rid of the dependency if that package disappears. I see no immediate reason to do so however.

Do you have any other concerns regarding that library?

@yurivict
Copy link
Author

Do you have any other concerns regarding that library?

I would like to create a FreeBSD port for sbv, but data-binary-ieee754 port is missing. Now I need create a port for the obsolete library, that is going to be used only for sbv.

@LeventErkok
Copy link
Owner

Note that SBV depends on CrackNum (http://hackage.haskell.org/package/crackNum) which also has a dependence on data-binary-ieee754. We'll need to remove it from both. If there are other transitive dependencies (I doubt it, but something to check), those will have to be removed as well.)

I'm not familiar with the process of porting to FreeBSD; is there a reason why "cabal install sbv" doesn't just work?

@yurivict
Copy link
Author

I'm not familiar with the process of porting to FreeBSD; is there a reason why "cabal install sbv" doesn't just work?

Yes, there is a reason. 'cabal install sbv' can't be run because it downloads files, and all downloaded files need to be fingerprinted for security reasons, so such commands can't be used in ports. It's the same for Debian, etc.

@LeventErkok LeventErkok changed the title [question] Why do yo use the obsolete library data-binary-ieee754 ? Deprecate dependence on data-binary-ieee754 Jul 22, 2018
@LeventErkok LeventErkok added this to the 7.11 milestone Jul 22, 2018
@LeventErkok
Copy link
Owner

Looks like this package is a drop-in-replacement that we can use: http://hackage.haskell.org/package/reinterpret-cast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants