fn create_set_label_value() -> CellRef {
    // Called on a monad that will return a label ID cell
    let create_set_label_flat_map = FnMonad::from(|(label_id_monad, ): (CellRef, )| {
        let label_id = BitCodeMonad::from_cell(&label_id_monad).expect("Label ID is not a monad");

        // Create the flat_map function
        let set_label_value = FnMonad::from(move |(label_value, ): (CellRef, )| {
            // Flat_map to store the position read by the bit_pos monad
            let set_label_value = label_id.clone().flat_map(move |label_id| { 
                Ok(BitCodeMonad::set_label_value(label_id, label_value.clone())) 
            }).expect("Failed to map set_label_value");
            let set_label_value = SafasCell::Any(Box::new(set_label_value)).into();

            let monad_type  = MonadType::new(BITCODE_FLAT_MAP.clone());

            CellRef::new(SafasCell::Monad(set_label_value, monad_type))
        });
        let set_label_value = ReturnsMonad(set_label_value);

        // Return as a framemonad
        CellRef::new(SafasCell::FrameMonad(Box::new(set_label_value)))
    });

    let create_set_label_flat_map = SafasCell::FrameMonad(Box::new(create_set_label_flat_map));

    create_set_label_flat_map.into()
}
///
/// Creates a 'set label value' closure function (this is a function that receives a label ID and returns a flat_map function that sets that label)
///
Creates a 'set label value' closure function (this is a function that receives a label ID and returns a flat_map function that sets that label)
Creates a ' set label value ' closure function ( this is a function that receives a label ID and returns a flat_map function that sets that label )
fn create_set_label_value() -> CellRef {
    // Called on a monad that will return a label ID cell
    let create_set_label_flat_map = FnMonad::from(|(label_id_monad, ): (CellRef, )| {
        let label_id = BitCodeMonad::from_cell(&label_id_monad).expect("Label ID is not a monad");
        // Create the flat_map function
        let set_label_value = FnMonad::from(move |(label_value, ): (CellRef, )| {
            // Flat_map to store the position read by the bit_pos monad
            let set_label_value = label_id.clone().flat_map(move |label_id| { 
                Ok(BitCodeMonad::set_label_value(label_id, label_value.clone())) 
            }).expect("Failed to map set_label_value");
            let set_label_value = SafasCell::Any(Box::new(set_label_value)).into();
            let monad_type  = MonadType::new(BITCODE_FLAT_MAP.clone());
            CellRef::new(SafasCell::Monad(set_label_value, monad_type))
        });
        let set_label_value = ReturnsMonad(set_label_value);
        // Return as a framemonad
        CellRef::new(SafasCell::FrameMonad(Box::new(set_label_value)))
    });
    let create_set_label_flat_map = SafasCell::FrameMonad(Box::new(create_set_label_flat_map));
    create_set_label_flat_map.into()
}
fn create_set_label_value ( ) -> CellRef { // Called on a monad that will return a label ID cell let create_set_label_flat_map = FnMonad :: from ( | ( label_id_monad , ) : ( CellRef , ) | { let label_id = BitCodeMonad :: from_cell ( & label_id_monad ) . expect ( " " ) ; // Create the flat_map function let set_label_value = FnMonad :: from ( move | ( label_value , ) : ( CellRef , ) | { // Flat_map to store the position read by the bit_pos monad let set_label_value = label_id . clone ( ) . flat_map ( move | label_id | { Ok ( BitCodeMonad :: set_label_value ( label_id , label_value . clone ( ) ) ) } ) . expect ( " " ) ; let set_label_value = SafasCell :: Any ( Box :: new ( set_label_value ) ) . into ( ) ; let monad_type = MonadType :: new ( BITCODE_FLAT_MAP . clone ( ) ) ; CellRef :: new ( SafasCell :: Monad ( set_label_value , monad_type ) ) } ) ; let set_label_value = ReturnsMonad ( set_label_value ) ; // Return as a framemonad CellRef :: new ( SafasCell :: FrameMonad ( Box :: new ( set_label_value ) ) ) } ) ; let create_set_label_flat_map = SafasCell :: FrameMonad ( Box :: new ( create_set_label_flat_map ) ) ; create_set_label_flat_map . into ( ) }
Creates a 'set label value' closure function (this is a function that receives a label ID and returns a flat_map function that sets that label)
Creates a ' set label value ' closure function ( this is a function that receives a label ID and returns a flat_map function that sets that label )