pub fn d_fn() -> impl FrameMonad<Binding=RuntimeResult> {
    ReturnsMonad(FnMonad::from(|values: Vec<CellRef>| {
        use self::SafasNumber::*;
        use self::BitCode::Bits;

        // Generate the bitcode
        let bitcode = values.into_iter().map(|value| {
            match &*value {
                SafasCell::Number(num) => {
                    match *num {
                        Plain(val)                      => Ok(vec![Bits(32, val)]),
                        BitNumber(bit_count, val)       => Ok(vec![Bits(bit_count, val)]),
                        SignedBitNumber(bit_count, val) => Ok(vec![Bits(bit_count, val as u128)])
                    }
                },

                SafasCell::String(string) => {
                    Ok(iter::once(BitCode::Align(8, 0, 8))
                        .chain(string.bytes()
                            .map(|byte| Bits(8, byte as u128)))
                        .collect())
                },

                SafasCell::Nil => { Ok(vec![Bits(32, 0)]) },

                _ => Err(RuntimeError::NotANumber(value))
            }
        }).collect::<Result<Vec<_>, _>>()?;

        // Create a bitcode monad cell
        let bitcode_monad   = BitCodeMonad::write_bitcode(bitcode.into_iter().flatten());
        Ok(bitcode_monad.to_cell())
    }))
}
///
/// The 'd' data output function
/// 
/// `(d $ffu8)` generates a bitcode monad that writes out a single byte
/// 
The 'd' data output function
`(d $ffu8)` generates a bitcode monad that writes out a single byte
The ' d ' data output function ` ( d $ffu8 ) ` generates a bitcode monad that writes out a single byte
pub fn d_fn() -> impl FrameMonad<Binding=RuntimeResult> {
    ReturnsMonad(FnMonad::from(|values: Vec<CellRef>| {
        use self::SafasNumber::*;
        use self::BitCode::Bits;
        // Generate the bitcode
        let bitcode = values.into_iter().map(|value| {
            match &*value {
                SafasCell::Number(num) => {
                    match *num {
                        Plain(val)                      => Ok(vec![Bits(32, val)]),
                        BitNumber(bit_count, val)       => Ok(vec![Bits(bit_count, val)]),
                        SignedBitNumber(bit_count, val) => Ok(vec![Bits(bit_count, val as u128)])
                    }
                },
                SafasCell::String(string) => {
                    Ok(iter::once(BitCode::Align(8, 0, 8))
                        .chain(string.bytes()
                            .map(|byte| Bits(8, byte as u128)))
                        .collect())
                },
                SafasCell::Nil => { Ok(vec![Bits(32, 0)]) },
                _ => Err(RuntimeError::NotANumber(value))
            }
        }).collect::<Result<Vec<_>, _>>()?;
        // Create a bitcode monad cell
        let bitcode_monad   = BitCodeMonad::write_bitcode(bitcode.into_iter().flatten());
        Ok(bitcode_monad.to_cell())
    }))
}
pub fn d_fn ( ) -> impl FrameMonad < Binding = RuntimeResult > { ReturnsMonad ( FnMonad :: from ( | values : Vec < CellRef > | { use self :: SafasNumber :: * ; use self :: BitCode :: Bits ; // Generate the bitcode let bitcode = values . into_iter ( ) . map ( | value | { match & * value { SafasCell :: Number ( num ) => { match * num { Plain ( val ) => Ok ( vec ! [ Bits ( 32 val ) ] ) , BitNumber ( bit_count , val ) => Ok ( vec ! [ Bits ( bit_count val ) ] ) , SignedBitNumber ( bit_count , val ) => Ok ( vec ! [ Bits ( bit_count val as u128 ) ] ) } } , SafasCell :: String ( string ) => { Ok ( iter :: once ( BitCode :: Align ( 8 , 0 , 8 ) ) . chain ( string . bytes ( ) . map ( | byte | Bits ( 8 , byte as u128 ) ) ) . collect ( ) ) } , SafasCell :: Nil => { Ok ( vec ! [ Bits ( 32 0 ) ] ) } , _ => Err ( RuntimeError :: NotANumber ( value ) ) } } ) . collect :: < Result < Vec < _ > , _ > > ( ) ? ; // Create a bitcode monad cell let bitcode_monad = BitCodeMonad :: write_bitcode ( bitcode . into_iter ( ) . flatten ( ) ) ; Ok ( bitcode_monad . to_cell ( ) ) } ) ) }
The 'd' data output function
`(d $ffu8)` generates a bitcode monad that writes out a single byte
The ' d ' data output function ` ( d $ffu8 ) ` generates a bitcode monad that writes out a single byte