haskell - Is there a way to `fromIntegral . fromEnum` that works with all Integers? -



haskell - Is there a way to `fromIntegral . fromEnum` that works with all Integers? -

> (fromintegral . fromenum) true 1

good.

> (fromintegral . fromenum) (10000 :: int) 10000

good.

λ (fromintegral . fromenum) 100000000000000000000 7766279631452241920

not good.

i'm doing bit banging data.bits , looking general way combine fields represented bool, int , integer. integer fields may large.

update

the overall thing i'm trying looks this:

fromexchange :: exchange -> integer fromexchange e = foldr combinebits 0 collectbits combinebits = ((.|.) . ($ e)) collectbits = [ (`shiftl` 127) . tobits . docommand , (`shiftl` 126) . tobits . readcomplete , (`shiftl` 116) . fromintegral . destid , (`shiftl` 64) . address , payload , (`shiftl` 108) . fromintegral . mask , (`shiftl` 104) . fromintegral . fromcommand . command ] tobits :: enum => -> integer tobits = fromintegral . fromenum

i'd factor out tobits/fromintegral if possible.

haskell

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -